public async Task CommitRollbackUnitOfWork1() { var unitOfWork = new InmemoryUnitOfWork(); var set = await unitOfWork.CreateSet <Account>(); var account = new Account { Email = this.UniqueEmail, Name = "misha" }; account.EnsureIdentity(); set.Add(account.Id, account); await unitOfWork.Commit(); var set1 = await unitOfWork.CreateSet <Account>(); var count = set1.Count; var account1 = new Account { Email = this.UniqueEmail, Name = "misha" }; account1.EnsureIdentity(); set1.Add(account1.Id, account1); await unitOfWork.Rollback(); var set3 = await unitOfWork.CreateSet <Account>(); Assert.AreEqual(count, set3.Count); }
public async Task ScopeableUnitOfWorkFactorySubRollback() { var unitOfWork = new InmemoryUnitOfWork(); var f = new ScopeableUnitOfWorkFactory(unitOfWork); var repo = new Repository <EventRelationType>(unitOfWork); var count = (await repo.GetFiltered(x => true)).Count(); using (f.Create()) { await repo.Add(new EventRelationType { Name = "x4" }); using (f.Create()) { await repo.Add(new EventRelationType { Name = "x5" }); } await unitOfWork.Rollback(); } Assert.AreEqual(count, (await repo.GetFiltered(x => true)).Count()); }