public CQRSDbContext GetDbContext(bool useSqlLite = false) { var builder = new DbContextOptionsBuilder <CQRSDbContext>(); if (useSqlLite) { builder.UseSqlite("DataSource=:memory:", x => { }); } else { builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); } var dbContext = new CQRSDbContext(builder.Options); if (useSqlLite) { // SQLite needs to open connection to the DB. // Not required for in-memory-database. dbContext.Database.OpenConnection(); } dbContext.Database.EnsureCreated(); return(dbContext); }
public static CQRSDbContext Create() { var options = new DbContextOptionsBuilder <CQRSDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new CQRSDbContext(options); context.Database.EnsureCreated(); context.Customers.AddRange(new[] { new Customer { CustomerId = "ADAM", ContactName = "Adam Cogan" }, new Customer { CustomerId = "JASON", ContactName = "Jason Taylor" }, new Customer { CustomerId = "BREND", ContactName = "Brendan Richards" }, }); context.SaveChanges(); return(context); }
public PersonRepository(CQRSDbContext context) { _context = context; }
public CommandTestBase() { _context = CQRSContextFactory.Create(); }
public GetCustomersListQueryHandlerTests(QueryTestFixture fixture) { _context = fixture.Context; _mapper = fixture.Mapper; }
public static void Destroy(CQRSDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public GetCustomerDetailQueryHandlerTests(QueryTestFixture fixture) { _context = fixture.Context; }