public void FromEnvironmentShouldExtractPassword() { // Arrange IEventBusBuilder builder = new EventBusBuilder(); // Act var result = builder.FromEnvironment(); // Assert Assert.AreEqual("TestPassword", result.Password); }
public void FromEnvironmentShouldExtractExchangeName() { // Arrange IEventBusBuilder builder = new EventBusBuilder(); // Act var result = builder.FromEnvironment(); // Assert Assert.AreEqual("TestExchangeName", result.ExchangeName); }
public void FromEnvironmentShouldExtractPort() { // Arrange IEventBusBuilder builder = new EventBusBuilder(); // Act var result = builder.FromEnvironment(); // Assert Assert.AreEqual(5000, result.Port); }
public void FromEnvironmentShouldReturnInstanceOfTypeIEventBusBuilder() { // Arrange IEventBusBuilder builder = new EventBusBuilder(); // Act var result = builder.FromEnvironment(); // Assert Assert.IsInstanceOfType(result, typeof(IEventBusBuilder)); }
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); }
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); }
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)); }