public async Task Check_CrudGetAll(WebApplicationFactoryType factoryType) { // Arrange var factory = GetFactory(factoryType); HttpClient client = factory.CreateClient(); // Act var items = await client.GetFromJsonAsync <List <xCore.Endpoints.Agenda> >($"/api/{nameof(Agenda)}"); _output.Write(JsonSerializer.Serialize(items, new JsonSerializerOptions { WriteIndented = true })); // Assert Assert.NotNull(items); Assert.True(factoryType == WebApplicationFactoryType.Development ? items.Any() : !items.Any()); }
public async Task Check_CrudCreate(WebApplicationFactoryType factoryType) { // Arrange var factory = GetFactory(factoryType); HttpClient client = factory.CreateClient(); Agenda item = new() { Title = $"You have to _____-{DateTime.Now}" }; // Act var response = await client.PostAsJsonAsync <Agenda>($"/api/{nameof(Agenda)}", item); var created = await response.Content.ReadFromJsonAsync <Agenda>(); _output.Write(JsonSerializer.Serialize(created, new JsonSerializerOptions { WriteIndented = true })); // Assert Assert.True(response.IsSuccessStatusCode); Assert.NotNull(created); } }
protected WebApplicationFactory <Program> GetFactory(WebApplicationFactoryType factoryType) => factoryType switch {
public void Check_DecoratorChainTypeByEnvironment(Type Tinterface, Type ExpectedTimplementation, WebApplicationFactoryType factoryType) => base.Check_ServiceImplementation(Tinterface, ExpectedTimplementation, factoryType);