예제 #1
0
        public void FromEnvironmentShouldExtractPassword()
        {
            // Arrange
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = builder.FromEnvironment();

            // Assert
            Assert.AreEqual("TestPassword", result.Password);
        }
예제 #2
0
        public void FromEnvironmentShouldExtractExchangeName()
        {
            // Arrange
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = builder.FromEnvironment();

            // Assert
            Assert.AreEqual("TestExchangeName", result.ExchangeName);
        }
예제 #3
0
        public void FromEnvironmentShouldExtractPort()
        {
            // Arrange
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = builder.FromEnvironment();

            // Assert
            Assert.AreEqual(5000, result.Port);
        }
예제 #4
0
        public void FromEnvironmentShouldReturnInstanceOfTypeIEventBusBuilder()
        {
            // Arrange
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = builder.FromEnvironment();

            // Assert
            Assert.IsInstanceOfType(result, typeof(IEventBusBuilder));
        }
예제 #5
0
        public void FromEnvironmentShouldThrowExceptionIfExchangeNameEnvironmentVariableIsNull()
        {
            // Arrange
            Environment.SetEnvironmentVariable("EXCHANGE_NAME", null);
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = Assert.ThrowsException <InvalidEnvironmentException>(() => builder.FromEnvironment());

            // Assert
            Assert.AreEqual("Environment variable [EXCHANGE_NAME] can not be null", result.Message);
        }
예제 #6
0
        public void CreateEventBusShouldCreateEventBusWithExchangeName()
        {
            // Arrange
            var modelMock      = new Mock <IModel>();
            var model          = modelMock.Object;
            var connectionMock = new Mock <IConnection>();
            var connection     = connectionMock.Object;
            var factoryMock    = new Mock <IConnectionFactory>();
            var factory        = factoryMock.Object;

            connectionMock.Setup(mock => mock.CreateModel()).Returns(model);
            factoryMock.Setup(mock => mock.CreateConnection()).Returns(connection);
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            var result = builder.FromEnvironment().CreateEventBus(factory);

            // Assert
            Assert.AreEqual("TestExchangeName", result.ExchangeName);
        }
예제 #7
0
        public void CreateEventBusShouldDeclareExchange()
        {
            // Arrange
            var modelMock      = new Mock <IModel>();
            var model          = modelMock.Object;
            var connectionMock = new Mock <IConnection>();
            var connection     = connectionMock.Object;
            var factoryMock    = new Mock <IConnectionFactory>();
            var factory        = factoryMock.Object;

            connectionMock.Setup(mock => mock.CreateModel()).Returns(model);
            factoryMock.Setup(mock => mock.CreateConnection()).Returns(connection);
            IEventBusBuilder builder = new EventBusBuilder();

            // Act
            builder.FromEnvironment().CreateEventBus(factory);

            // Assert
            connectionMock.Verify(mock => mock.CreateModel());
            modelMock.Verify(mock => mock.ExchangeDeclare("TestExchangeName", ExchangeType.Topic, false, false, null));
        }