/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/csharp/csharp-505-4516-002/main.cs
31 строка
827 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
using System.Net.Http.Json; using Microsoft.AspNetCore.Mvc.Testing; namespace HelloApi.Tests; public class NotesEndpointTests : IClassFixture<WebApplicationFactory<Program>> { private readonly HttpClient _client; public NotesEndpointTests(WebApplicationFactory<Program> factory) { _client = factory.CreateClient(); } [Fact] public async Task PostNote_ThenGetAll_ContainsNote() { var create = await _client.PostAsJsonAsync( "/api/notes", new { Text = "integration test" }); create.EnsureSuccessStatusCode(); var notes = await _client.GetFromJsonAsync<List<NoteDto>>("/api/notes"); Assert.NotNull(notes); Assert.Contains(notes, n => n.Text == "integration test"); } private record NoteDto(int Id, string Text); }