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(); }
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()); }
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()); }
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()); }
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(); }