Пример #1
0
        public void CanCallCommitOnTheUnitOfWorkAndItCallsSaveChangesOnTheDbContext()
        {
            MockDbContext.Setup(c => c.SaveChanges()).Returns(0);

            var uow = new TestUoW(MockRepositoryProvider.Object, MockDbContextFactory.Object);

            uow.Commit();
        }
Пример #2
0
        public void CanUseTheUnitOfWorkToGetCustomRepositoryFrom()
        {
            Mock <IPersonRepository> mockCustomRepository = new Mock <IPersonRepository>();

            MockRepositoryProvider.Setup(rp => rp.GetRepository <IPersonRepository>(null)).Returns(mockCustomRepository.Object);

            var uow = new TestUoW(MockRepositoryProvider.Object, MockDbContextFactory.Object);

            var customRepository = uow.CustomRepository;

            Assert.IsNotNull(customRepository);
        }
Пример #3
0
        public void CanUseTheUnitOfWorkToGetGenericRepository()
        {
            Mock <IRepository <Person> > mockGenericRepository = new Mock <IRepository <Person> >();

            MockRepositoryProvider.Setup(rp => rp.GetRepositoryForEntityType <Person>()).Returns(mockGenericRepository.Object);

            var uow = new TestUoW(MockRepositoryProvider.Object, MockDbContextFactory.Object);

            var genericRepository = uow.GenericRepository;

            Assert.IsNotNull(genericRepository);
        }