Esempio n. 1
0
 public virtual void Initialize()
 {
     DataService = new DummyMysqlDataService();
     DataService.RegisterRepositoryProvider(
         new Func <IUnitOfWork, IDummyRepository>(work => new DummyRepository(work)));
     UnitOfWork = DataService.BeginUnitOfWork();
     Repository = UnitOfWork.GetRepository <IDummyRepository>();
 }
Esempio n. 2
0
        public void TestCommit()
        {
            using (var dataService = new DummyMysqlDataService())
            {
                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();
                }

                using (var uow = dataService.BeginUnitOfWork())
                {
                    var repo = uow.GetRepository <IDummyRepository>();

                    Assert.AreEqual(repo.GetAll().Count(), 1);
                    repo.Delete(repo.GetAll().First());
                    uow.Commit();
                }
            }
        }