public AnalyticTest(TestWebApplicationFactory <Startup> factory)
        {
            _client = factory.WithWebHostBuilder(builder =>
            {
                builder.ConfigureServices(services =>
                {
                    var serviceProvider = services.BuildServiceProvider();

                    using (var scope = serviceProvider.CreateScope())
                    {
                        var scopedServices = scope.ServiceProvider;
                        var db             = scopedServices.GetRequiredService <ESHContext>();

                        // Ensure the database is created.
                        db.Database.OpenConnection();
                        try
                        {
                            db.Database.ExecuteSqlCommand(@"
                            Drop table Supplies                        
                            Drop table EquipmentTypes
                        Drop table Suppliers
                        ");
                        }
                        catch (Exception) { }
                        finally { }

                        db.Database.EnsureCreated();
                        Utilities.DBInitializer.InitializeDbForTests(db);
                    }
                });
            })
                      .CreateClient(new WebApplicationFactoryClientOptions
            {
                AllowAutoRedirect = false
            });
        }
Esempio n. 2
0
 public SupplierControllerTest(TestWebApplicationFactory <Startup> factory)
 {
     CrudClient = new SupplierCRUDClient(factory);
 }
 public EquipmentControllerTest(TestWebApplicationFactory <Startup> factory)
 {
     CrudClient = new EquipmentTypeCRUDClient(factory);
 }
 public DeliveryControllerTest(TestWebApplicationFactory <Startup> factory)
 {
     CrudClient          = new DeliveryCRUDClient(factory);
     EquipmentCRUDClient = new EquipmentTypeCRUDClient(factory);
     SupplierCRUDClient  = new SupplierCRUDClient(factory);
 }