using Microsoft.AspNetCore.Mvc.Testing; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; using Xunit.Extensions; using Xunit.Sdk; using XUnitDIStudy.Model; namespace XUnitDIStudy.Test.IntegrationTest { [Collection(TestConst.IntegrationCollectionDefinitionKey)] public class DefaultWebApplicationFactoryTest { private readonly WebApplicationFactory _factory; public DefaultWebApplicationFactoryTest(WebApplicationFactory factory) { _factory = factory; } [Fact] public async Task TestAsync() { // Arrange var client = _factory.CreateClient(); // Act var response = await client.GetAsync("/Default/GetAll"); // Assert response.EnsureSuccessStatusCode(); // Status Code 200-299 List result = System.Text.Json.JsonSerializer.Deserialize>(response.Content.ReadAsStringAsync().Result); Assert.NotNull(result); Assert.True(result.Count > 0); } } }