public static void ClassInitialize(TestContext testContext) { container = DependencyResolution.IoC.Initialize(); var contextFactory = container.GetInstance<IDbContextFactory<HealthCheckDbContext>>(); dbContext = contextFactory.Build(); Assert.IsNotNull(dbContext); }
public static void ClassInitialize(TestContext testContext) { container = DependencyResolution.IoC.Initialize(); var contextFactory = container.GetInstance <IDbContextFactory <HealthCheckDbContext> >(); dbContext = contextFactory.Build(); Assert.IsNotNull(dbContext); }
public void Test03TestOnDelete() { dbCreated = true; var test = new Test { Name = "Test", ClientApplication = new ClientApplication { Name = "Test app", Key = Guid.NewGuid(), IsActive = true }, IsActive = true, Key = "Test" }; dbContext.Tests.Add(test); // save and refresh context dbContext.SaveChanges(); dbContext.Dispose(); var contextFactory = container.GetInstance <IDbContextFactory <HealthCheckDbContext> >(); dbContext = contextFactory.Build(); var beforeDelete = dbContext.Tests.Count(); Assert.IsTrue(beforeDelete > 0, "No tests after save."); var test2 = dbContext.Tests.First(g => g.Id == test.Id); // reload from new context dbContext.Tests.Remove(test2); dbContext.SaveChanges(); int afterDelete = dbContext.Tests.Count(); Assert.AreEqual(beforeDelete - 1, afterDelete, "Tests should be deleted."); }
public void Test03TestOnDelete() { dbCreated = true; var test = new Test { Name = "Test", ClientApplication = new ClientApplication { Name = "Test app", Key = Guid.NewGuid(), IsActive = true }, IsActive = true, Key = "Test" }; dbContext.Tests.Add(test); // save and refresh context dbContext.SaveChanges(); dbContext.Dispose(); var contextFactory = container.GetInstance<IDbContextFactory<HealthCheckDbContext>>(); dbContext = contextFactory.Build(); var beforeDelete = dbContext.Tests.Count(); Assert.IsTrue(beforeDelete > 0, "No tests after save."); var test2 = dbContext.Tests.First(g => g.Id == test.Id); // reload from new context dbContext.Tests.Remove(test2); dbContext.SaveChanges(); int afterDelete = dbContext.Tests.Count(); Assert.AreEqual(beforeDelete - 1, afterDelete, "Tests should be deleted."); }
public UnitOfWork(HealthCheckDbContext context) { _context = context; AppRepository = new AppRepository(_context); AppCheckHistoryRepository = new AppCheckHistoryRepository(_context); }