示例#1
0
        public void TestCommit()
        {
            using (var dataService = new DummyMssqlDataService())
            {
                dataService.RegisterRepositoryProvider(
                    new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work)));
                using (var uow = dataService.BeginUnitOfWork())
                {
                    var repo = uow.GetRepository <IDummyRepository>();
                    repo.Add(new DummyEntity());
                    uow.Commit();
                    uow.Dispose();
                }
            }

            using (var dataService = new DummyMssqlDataService())
            {
                dataService.RegisterRepositoryProvider(
                    new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work)));
                using (var uow = dataService.BeginUnitOfWork())
                {
                    var repo = uow.GetRepository <IDummyRepository>();

                    Assert.AreEqual(repo.GetAll().Count(), 1);
                    repo.Delete(repo.GetAll().First());
                    uow.Commit();
                    uow.Dispose();
                }
            }
        }
示例#2
0
 public virtual void Initialize()
 {
     DataService = new DummyMssqlDataService();
     DataService.RegisterRepositoryProvider(
         new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work)));
     UnitOfWork = DataService.BeginUnitOfWork();
     Repository = UnitOfWork.GetRepository <IDummyRepository>();
 }