public void TestCommit() { using (var dataService = new DummySqLiteDataService()) { dataService.RegisterRepositoryProvider( new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work))); using (var uow = dataService.BeginUnitOfWork()) { var repo = uow.GetRepository <IDummyRepository>(); repo.Add(new DummyEntity { Name = "Test X" }); uow.Commit(); } using (var uow = dataService.BeginUnitOfWork()) { var repo = uow.GetRepository <IDummyRepository>(); Assert.AreEqual(repo.GetAll().Count(), 1); repo.Delete(repo.GetAll().First()); uow.Commit(); } } }
public virtual void Initialize() { DataService = new DummySqLiteDataService(); DataService.RegisterRepositoryProvider( new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work))); UnitOfWork = DataService.BeginUnitOfWork(); Repository = UnitOfWork.GetRepository <IDummyRepository>(); }