/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Identity/test/Identity.FunctionalTests/Extensions/ResponseAssert.cs
58 строк
2 KB
Youssef Fahmy
Update AngleSharp to latest (#67898)
20 июл 2026, 15:48
Не верифицирован
20 июл 2026, 15:48
fc4e6e0
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net; using System.Net.Http; using System.Net.Http.Headers; using AngleSharp; using AngleSharp.Html.Dom; using AngleSharp.Io; namespace Microsoft.AspNetCore.Identity.FunctionalTests; public static class ResponseAssert { public static Uri IsRedirect(HttpResponseMessage responseMessage) { Assert.Equal(HttpStatusCode.Redirect, responseMessage.StatusCode); return responseMessage.Headers.Location; } public static async Task<IHtmlDocument> IsHtmlDocumentAsync(HttpResponseMessage response) { Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); var content = await response.Content.ReadAsStringAsync(); var document = await BrowsingContext.New() .OpenAsync(ResponseFactory, CancellationToken.None); return Assert.IsAssignableFrom<IHtmlDocument>(document); void ResponseFactory(VirtualResponse htmlResponse) { htmlResponse .Address(response.RequestMessage.RequestUri) .Status(response.StatusCode); MapHeaders(response.Headers); MapHeaders(response.Content.Headers); htmlResponse.Content(content); void MapHeaders(HttpHeaders headers) { foreach (var header in headers) { foreach (var value in header.Value) { htmlResponse.Header(header.Key, value); } } } } } internal static void IsOK(HttpResponseMessage download) { Assert.Equal(HttpStatusCode.OK, download.StatusCode); } }