public void AssignHostAddress_DefaultPort_PropertiesAreValid() { var options = new ActiveMqOptions { HostAddress = new Uri("activemq://localhost:61616") }; Assert.Equal("localhost", options.Host); Assert.Equal(61616, options.Port); }
public void AssignProperties_HostAddressIsValid() { var options = new ActiveMqOptions { Host = "localhost", Port = 8080, }; Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(8080, options.HostAddress.Port); }
public void AssignHostAddress_EmptyPort_PropertiesAreValid() { var options = new ActiveMqOptions { HostAddress = new Uri("activemq://localhost") }; Assert.Equal("localhost", options.Host); Assert.Equal("localhost", options.HostAddress.Host); Assert.Null(options.Port); }
public void DefaultCtor_IsValid() { var options = new ActiveMqOptions(); Assert.Equal(string.Empty, options.ConnectionName); Assert.Equal(new Uri("activemq:/"), options.HostAddress); Assert.Null(options.Host); Assert.Null(options.Port); Assert.Null(options.Username); Assert.Null(options.Password); }
public void AssignHostAddress_OtherPort_PropertiesAreValid() { var options = new ActiveMqOptions { HostAddress = new Uri("activemq://localhost:8080/") }; Assert.Equal("localhost", options.Host); Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(8080, options.Port); }
public void AssignDefaultPort_WithoutSsl_HostAddressIsValid() { var options = new ActiveMqOptions { Host = "localhost", Port = 61616, }; Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(61616, options.HostAddress.Port); }
public void AssignZeroPort_HostAddressIsValid() { var options = new ActiveMqOptions { Host = "localhost", Port = 0, }; Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(-1, options.HostAddress.Port); }
public void AssignOtherPort_WithSsl_HostAddressIsValid() { var options = new ActiveMqOptions { Host = "localhost", Port = 8080, UseSsl = true, }; Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(8080, options.HostAddress.Port); }
public void AssignNullPort_WithSsl_HostAddressIsValid() { var options = new ActiveMqOptions { Host = "localhost", Port = null, UseSsl = true, }; Assert.Equal("localhost", options.HostAddress.Host); Assert.Equal(61617, options.HostAddress.Port); }
public async Task UseActiveMq_GivenStaticOptions_ThenValid() { var options = new ActiveMqOptions { ConnectionName = "connection-name-test", Host = "127.0.0.1", Port = 61616, Username = "******", Password = "******", }; var mockBusHandle = new Mock <BusHandle>(MockBehavior.Strict); var mockBusControl = new Mock <IBusControl>(MockBehavior.Strict); var mockActiveMqBusFactory = new Mock <IBusFactory <IActiveMqBusFactoryConfigurator> >(MockBehavior.Strict); var mockActiveMqBusFactoryConfigurator = new Mock <IActiveMqBusFactoryConfigurator>(MockBehavior.Strict); var mockActiveMqHost = new Mock <IActiveMqHost>(MockBehavior.Strict); mockBusControl .Setup(_ => _.StartAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(mockBusHandle.Object) .Verifiable(); mockBusControl .Setup(_ => _.StopAsync(It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask) .Verifiable(); mockActiveMqBusFactory .Setup(_ => _.Create(It.IsAny <Action <IActiveMqBusFactoryConfigurator> >())) .Callback((Action <IActiveMqBusFactoryConfigurator> configure) => configure(mockActiveMqBusFactoryConfigurator.Object)) .Returns(mockBusControl.Object) .Verifiable(); mockActiveMqBusFactoryConfigurator .Setup(_ => _.Host(It.IsAny <ActiveMqHostSettings>())) .Callback((ActiveMqHostSettings settings) => { Assert.Equal(options.Host, settings.Host); Assert.Equal(options.Port, settings.Port); Assert.Equal(options.Username, settings.Username); Assert.Equal(options.Password, settings.Password); }) .Returns(mockActiveMqHost.Object) .Verifiable(); var services = new ServiceCollection(); services.AddSingleton(mockActiveMqBusFactory.Object); services.AddLogging(builder => { builder.SetMinimumLevel(LogLevel.Trace); builder.AddXUnit(_output); }); services.AddMassTransit(builder => { builder.UseActiveMq(options); }); using (var serviceProvider = services.BuildServiceProvider()) { var busManager = serviceProvider.GetRequiredService <IBusManager>(); await busManager.StartAsync(CancellationToken.None).ConfigureAwait(false); var bus = busManager.GetBus(options.ConnectionName); Assert.NotNull(bus); await busManager.StopAsync(CancellationToken.None).ConfigureAwait(false); } mockActiveMqHost.Verify(); mockActiveMqBusFactoryConfigurator.Verify(); mockActiveMqBusFactory.Verify(); mockBusControl.Verify(); mockBusHandle.Verify(); }