Пример #1
0
 public BaseTest(MyWebApplicationFactory factory)
 {
     Factory = factory;
     Client  = factory.CreateClient(new WebApplicationFactoryClientOptions
     {
         AllowAutoRedirect = false
     });
 }
        public async Task returns_200_ok()
        {
            const string url = "books";

            using var factory = new MyWebApplicationFactory();
            var client = factory.CreateClient();

            using var response = await client.GetAsync(url);

            response.StatusCode.Should().Be(StatusCodes.Status200OK);
        }
Пример #3
0
        public BaseControllerTest(MyWebApplicationFactory factory)
        {
            Factory = factory;
            Client  = factory
                      .WithWebHostBuilder(builder =>
            {
                builder.ConfigureAppConfiguration((_, conf) =>
                {
                    var projectDir = Directory.GetCurrentDirectory();
                    var configPath = Path.Combine(projectDir, "appsettings.Test.json");

                    conf.AddJsonFile(configPath);
                });
                builder.ConfigureServices(services =>
                {
                    Console.WriteLine("\t--Configring services test-location-02");
                    services.ConfigureInMemoryDB();
                });
            })
                      .CreateClient(new WebApplicationFactoryClientOptions
            {
                AllowAutoRedirect = false
            });
        }