public void RabbitMQBusContextDisposesConnection()
        {
            Mock <IConnection> connectionMock = new Mock <IConnection>(MockBehavior.Strict);

            connectionMock.Setup(conn => conn.Dispose());
            var target = new RabbitMQBusContext(connectionMock.Object, "My.Test.ExchangeName");

            target.Dispose();

            connectionMock.Verify(c => c.Dispose());
        }
Пример #2
0
        public void CreateMessageSender_WithBusContextDisposed_ThrowsObjectDisposedException()
        {
            // Arrange
            var connectionMock = new Mock <IConnection>();

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

            context.Dispose();

            // Act & Assert
            Assert.ThrowsException <ObjectDisposedException>(() =>
            {
                context.CreateMessageSender();
            });
        }
Пример #3
0
        public void CreateMessageReceiver_WithBusContextDisposed_ThrowsObjectDisposedException()
        {
            // Arrange
            var connectionMock = new Mock <IConnection>();

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

            context.Dispose();

            // Act & Assert
            Assert.ThrowsException <ObjectDisposedException>(() =>
            {
                context.CreateMessageReceiver("TestQueue", new List <string> {
                    "topic.expression.a", "routing.key.b"
                });
            });
        }
 public void TestCleanup()
 {
     _context.Dispose();
 }
 private void OnShutdown()
 {
     _context.Dispose();
 }