Пример #1
0
        public void Flush_Calls_Underlying_DataContext_SubmitChanges()
        {
            var mockDataContext = MockRepository.GenerateMock <IEFSession>();

            mockDataContext.Expect(x => x.SaveChanges());

            var unitOfWork = new EFUnitOfWork(mockDataContext);

            unitOfWork.Flush();

            mockDataContext.VerifyAllExpectations();
        }
Пример #2
0
        public void Flush_calls_SubmitChanges_on_all_open_IEFSession_instances()
        {
            var resolver = MockRepository.GenerateMock<IEFSessionResolver>();
            resolver.Stub(x => x.GetSessionKeyFor<string>()).Return(Guid.NewGuid());
            resolver.Stub(x => x.GetSessionKeyFor<int>()).Return(Guid.NewGuid());
            resolver.Stub(x => x.OpenSessionFor<string>()).Return(MockRepository.GenerateStub<IEFSession>());
            resolver.Stub(x => x.OpenSessionFor<int>()).Return(MockRepository.GenerateStub<IEFSession>());

            var unitOfWork = new EFUnitOfWork(resolver);
            unitOfWork.GetSession<string>();
            unitOfWork.GetSession<int>();

            unitOfWork.Flush();
            resolver.OpenSessionFor<string>().AssertWasCalled(x => x.SaveChanges());
            resolver.OpenSessionFor<int>().AssertWasCalled(x => x.SaveChanges());
        }
Пример #3
0
        public void Flush_calls_SubmitChanges_on_all_open_IEFSession_instances()
        {
            var resolver = MockRepository.GenerateMock <IEFSessionResolver>();

            resolver.Stub(x => x.GetSessionKeyFor <string>()).Return(Guid.NewGuid());
            resolver.Stub(x => x.GetSessionKeyFor <int>()).Return(Guid.NewGuid());
            resolver.Stub(x => x.OpenSessionFor <string>()).Return(MockRepository.GenerateStub <IEFSession>());
            resolver.Stub(x => x.OpenSessionFor <int>()).Return(MockRepository.GenerateStub <IEFSession>());

            var unitOfWork = new EFUnitOfWork(resolver);

            unitOfWork.GetSession <string>();
            unitOfWork.GetSession <int>();

            unitOfWork.Flush();
            resolver.OpenSessionFor <string>().AssertWasCalled(x => x.SaveChanges());
            resolver.OpenSessionFor <int>().AssertWasCalled(x => x.SaveChanges());
        }
Пример #4
0
        public void Flush_calls_SubmitChanges_on_all_open_IEFSession_instances()
        {
            var resolver = new Mock<IEFSessionResolver>();
            resolver.Setup(x => x.GetSessionKeyFor<string>()).Returns(Guid.NewGuid());
            resolver.Setup(x => x.GetSessionKeyFor<int>()).Returns(Guid.NewGuid());
            var session = new Mock<IEFSession>();
            resolver.Setup(x => x.OpenSessionFor<string>()).Returns(session.Object);
            resolver.Setup(x => x.OpenSessionFor<int>()).Returns(session.Object);

            var unitOfWork = new EFUnitOfWork(resolver.Object);
            unitOfWork.GetSession<string>();
            unitOfWork.GetSession<int>();

            unitOfWork.Flush();
            resolver.Object.OpenSessionFor<string>();
            session.Verify(x => x.SaveChanges());
            resolver.Object.OpenSessionFor<int>();
            session.Verify(x => x.SaveChanges());
        }
Пример #5
0
        public void Flush_Calls_Underlying_DataContext_SubmitChanges()
        {
            var mockDataContext = MockRepository.GenerateMock<IEFSession>();
            mockDataContext.Expect(x => x.SaveChanges());

            var unitOfWork = new EFUnitOfWork(mockDataContext);
            unitOfWork.Flush();

            mockDataContext.VerifyAllExpectations();
        }