Example #1
0
    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());
    }
Example #2
0
    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);
    }
}
Example #3
0
 protected WebApplicationFactory <Program> GetFactory(WebApplicationFactoryType factoryType)
 => factoryType switch
 {
Example #4
0
 public void Check_DecoratorChainTypeByEnvironment(Type Tinterface, Type ExpectedTimplementation, WebApplicationFactoryType factoryType)
 => base.Check_ServiceImplementation(Tinterface, ExpectedTimplementation, factoryType);