public TestBase() { Context = ContextFactory.Create(); var config = new MapperConfiguration(cfg => { cfg.AddProfile <AutoMappingProfile>(); }); Mapper = config.CreateMapper(); }
public static void InitializeDbForTests(ApiGatewayDbContext context) { context.Routes.AddRange(new SeedRoutes().Seed()); context.AuthenticationOptions.AddRange(new SeedAuthenticationOptions().Seed()); context.GlobalConfigurations.AddRange(new SeedGlobalConfigurations().Seed()); context.LoadBalancerOptions.AddRange(new SeedLoadBalancerOptions().Seed()); context.DownstreamHostAndPorts.AddRange(new SeedDownstreamHostAndPorts().Seed()); context.RouteClaimsRequirements.AddRange(new SeedRouteClaimsRequirements().Seed()); context.SaveChanges(); }
private static SqliteConnection CreateDatabaseAndGetConnection() { var connection = new SqliteConnection("Data Source=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <ApiGatewayDbContext>() .UseSqlite(connection) .Options; using (var context = new ApiGatewayDbContext(options)) { context.GetService <IRelationalDatabaseCreator>().CreateTables(); } return(connection); }
public static ApiGatewayDbContext Create() { var options = new DbContextOptionsBuilder <ApiGatewayDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new ApiGatewayDbContext(options); context.Database.EnsureCreated(); context.Routes.AddRange(new SeedRoutes().Seed()); context.AuthenticationOptions.AddRange(new SeedAuthenticationOptions().Seed()); context.GlobalConfigurations.AddRange(new SeedGlobalConfigurations().Seed()); context.LoadBalancerOptions.AddRange(new SeedLoadBalancerOptions().Seed()); context.DownstreamHostAndPorts.AddRange(new SeedDownstreamHostAndPorts().Seed()); context.RouteClaimsRequirements.AddRange(new SeedRouteClaimsRequirements().Seed()); context.SaveChanges(); return(context); }
public static void Destroy(ApiGatewayDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }