Ejemplo n.º 1
0
        public void PauseThrowsExceptionIfAlreadyPaused()
        {
            // Arrange
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var receiver = new TestMessageReceiver(context.Object, "queue", new string[0]);

            receiver.StartReceivingMessages();

            receiver.Pause();

            // Act
            void Act() => receiver.Pause();

            // Assert
            BusConfigurationException exception = Assert.ThrowsException <BusConfigurationException>(Act);

            Assert.AreEqual("Attempting to pause the TestMessageReceiver, but it was already paused.", exception.Message);
        }
Ejemplo n.º 2
0
        public void PausePausesReceiver()
        {
            // Arrange
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var receiver = new TestMessageReceiver(context.Object, "queue", new string[0]);

            receiver.StartReceivingMessages();

            // Act
            receiver.Pause();

            // Assert
            Assert.IsTrue(receiver.IsPaused);
        }
Ejemplo n.º 3
0
        public void PauseThrowsExceptionWhenNotListening()
        {
            // Arrange
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var receiver = new TestMessageReceiver(context.Object, "queue", new string[0]);

            // Act
            void Act() => receiver.Pause();

            // Assert
            BusConfigurationException exception = Assert.ThrowsException <BusConfigurationException>(Act);

            Assert.AreEqual("Attempting to pause the TestMessageReceiver, but it is not even receiving messages.", exception.Message);
        }