Beispiel #1
0
        public void ShouldReturnsNewSessionBeforeEachCommand()
        {
            // Given
            var sessionFactory = new Mock <IMessageQueueSessionFactory>();

            // When
            var target = new MessageQueueSessionManagerPerCommand(sessionFactory.Object);

            target.OpenSession();
            target.OpenSession();

            // Then
            sessionFactory.Verify(m => m.OpenSession(), Times.Exactly(2));
        }
Beispiel #2
0
        public void ShouldDisposeSessionAfterCommand()
        {
            // Given
            var session = new Mock <IMessageQueueSession>();

            session.SetupGet(m => m.IsOpen).Returns(true);
            var sessionFactory = new Mock <IMessageQueueSessionFactory>();

            sessionFactory.Setup(m => m.OpenSession()).Returns(session.Object);

            // When
            var target        = new MessageQueueSessionManagerPerCommand(sessionFactory.Object);
            var actualSession = target.OpenSession();

            target.CloseSession(actualSession);

            // Then
            Assert.AreEqual(session.Object, actualSession);
            session.Verify(m => m.Dispose());
        }