public void PersistingDataTest() { var lookupCode = new LookupCode { Description = "desc" }; using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions())) { using (TransactionScope scope = new TransactionScope()) { using (TransactionScope scope2 = new TransactionScope()) { dbContext.LookupCode.Add(lookupCode); dbContext.SaveChanges(); scope2.Complete(); scope.Complete(); } } } using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions())) { var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id); Assert.NotNull(workSectionCode2); dbContext.Remove(workSectionCode2); dbContext.SaveChanges(); } }
public void RollbackDataTest() { var lookupCode = new LookupCode { Description = "desc" }; using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions())) { using (TransactionScope scope = new TransactionScope()) { using (TransactionScope scope2 = new TransactionScope()) { dbContext.LookupCode.Add(lookupCode); dbContext.SaveChanges(); scope2.Complete(); } //No scope complete, should rollback. } } using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions())) { var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id); Assert.Null(workSectionCode2); } }