public void ScopesAreInvalidatedOnConversationDisposal() { var sf = MockRepository.GenerateStub<ISessionFactory>(); var cc = MockRepository.GenerateStub<INhConversationContext>(); var c = new NhConversation(sf, cc); INhScope s = (INhScope)c.Scope(); Assert.That(s.IsValid); c.Dispose(); Assert.That(s.IsValid, Is.False); s.Dispose(); // Must not throw }
public void CanSwitchBetweenConversations() { NhConversationContext context = new NhConversationContext(); var sf = MockRepository.GenerateStub<ISessionFactory>(); var conv1 = new NhConversation(sf, context); var conv2 = new NhConversation(sf, context); Assert.That(context.CurrentConversation, Is.Null); using (conv1.Scope()) { Assert.That(context.CurrentConversation, Is.SameAs(conv1)); using (conv2.Scope()) { Assert.That(context.CurrentConversation, Is.SameAs(conv2)); } Assert.That(context.CurrentConversation, Is.SameAs(conv1)); } Assert.That(context.CurrentConversation, Is.Null); }
public void ScopeIsRegistered() { var sf = MockRepository.GenerateStub<ISessionFactory>(); var cc = MockRepository.GenerateMock<INhConversationContext>(); cc.Expect(m => m.RegisterScope(null)).IgnoreArguments(); var c = new NhConversation(sf, cc); using (c.Scope()) { } cc.VerifyAllExpectations(); }
public void ScopeIsDeregistered() { INhScope registeredScope = null; var sf = MockRepository.GenerateStub<ISessionFactory>(); var cc = MockRepository.GenerateMock<INhConversationContext>(); cc.Expect(m => m.RegisterScope(null)).IgnoreArguments().WhenCalled(i => registeredScope = (INhScope)i.Arguments[0]); var c = new NhConversation(sf, cc); using (c.Scope()) { cc.Expect(m => m.ReleaseScope(registeredScope)); } cc.VerifyAllExpectations(); }
public void CanCreateScope() { var sf = MockRepository.GenerateStub<ISessionFactory>(); var cc = MockRepository.GenerateStub<INhConversationContext>(); var c = new NhConversation(sf, cc); using (c.Scope()) { } }