Esempio n. 1
0
        public void HostCanBeStarted()
        {
            FakeHostedService service;

            using (var host = StreamHost.CreateDefaultBuilder <SampleSink>()
                              .ConfigureServices(svc => svc.AddSingleton <IHostedService, FakeHostedService>())
                              .Start())
            {
                Assert.NotNull(host);
                service = (FakeHostedService)host.Services.GetRequiredService <IHostedService>();
                Assert.NotNull(service);
                Assert.Equal(1, service.StartCount);
                Assert.Equal(0, service.StopCount);
                Assert.Equal(0, service.DisposeCount);
            }

            Assert.Equal(1, service.StartCount);
            Assert.Equal(0, service.StopCount);
            Assert.Equal(1, service.DisposeCount);
        }
Esempio n. 2
0
        public void HostConfiguresRabbitOptions()
        {
            IServiceCollection services = new ServiceCollection();

            Environment.SetEnvironmentVariable("VCAP_APPLICATION", TestHelpers.VCAP_APPLICATION);
            Environment.SetEnvironmentVariable("VCAP_SERVICES", GetCloudFoundryRabbitMqConfiguration());
            using (var host = StreamHost
                              .CreateDefaultBuilder <SampleSink>()
                              .ConfigureAppConfiguration(c => c.AddCloudFoundry())
                              .Start())
            {
                var rabbitOptionsMonitor = host.Services.GetService <IOptionsMonitor <RabbitOptions> >();
                Assert.NotNull(rabbitOptionsMonitor);
                var rabbitOptions = rabbitOptionsMonitor.CurrentValue;

                Assert.Equal("Dd6O1BPXUHdrmzbP", rabbitOptions.Username);
                Assert.Equal("7E1LxXnlH2hhlPVt", rabbitOptions.Password);
                Assert.Equal("cf_b4f8d2fa_a3ea_4e3a_a0e8_2cd040790355", rabbitOptions.VirtualHost);
                Assert.Equal($"Dd6O1BPXUHdrmzbP:[email protected]:3306", rabbitOptions.Addresses);
            }
        }