Пример #1
0
        public void EventMessageSenderDisposes()
        {
            var target = new RabbitMQMessageSender(_busContext);

            target.Dispose();

            _channelMock.Verify(c => c.Dispose());
        }
Пример #2
0
        public void SendMessage_WithSenderDisposed_ThrowsObjectDisposedException()
        {
            // Arrange
            var channelMock = new Mock <IModel>();

            var connectionMock = new Mock <IConnection>();

            connectionMock.Setup(c => c.CreateModel())
            .Returns(channelMock.Object);

            var context = new RabbitMQBusContext(connectionMock.Object, "Testexchange1");

            var sender = new RabbitMQMessageSender(context);

            sender.Dispose();

            // Act & Assert
            Assert.ThrowsException <ObjectDisposedException>(() =>
            {
                sender.SendMessage(new EventMessage("MyRoutingKey", "MyMessage"));
            });
        }