Example #1
0
        public void RegisterHealthMiddleware_RegistersComponents()
        {
            // Arrange
            ContainerBuilder   containerBuilder = new ContainerBuilder();
            IConfigurationRoot config           = new ConfigurationBuilder().Build();

            // Act
            HealthContainerBuilderExtensions.RegisterHealthActuator(containerBuilder, config);
            var container = containerBuilder.Build();

            // Assert
            Assert.True(container.IsRegistered <IHealthOptions>(), "Health options are registered");
            Assert.True(container.IsRegistered <IHealthContributor>(), "At least one health contributor registered");
            Assert.True(container.IsRegistered <HealthEndpoint>(), "Health endpoint is registered");
            Assert.True(container.IsRegistered <HealthEndpointOwinMiddleware>(), "Env endpoint middleware is registered");
        }
Example #2
0
        public void RegisterHealthMiddleware_ThrowsOnNulls()
        {
            // Arrange
            ContainerBuilder   containerNull    = null;
            ContainerBuilder   containerBuilder = new ContainerBuilder();
            IConfigurationRoot configNull       = null;
            IConfigurationRoot config           = new ConfigurationBuilder().Build();

            // Act
            var ex  = Assert.Throws <ArgumentNullException>(() => HealthContainerBuilderExtensions.RegisterHealthActuator(containerNull, config));
            var ex2 = Assert.Throws <ArgumentNullException>(() => HealthContainerBuilderExtensions.RegisterHealthActuator(containerBuilder, configNull));

            // Assert
            Assert.Equal("container", ex.ParamName);
            Assert.Equal("config", ex2.ParamName);
        }