public DefaultHealthResponseWriter( IHealthOutputFormatter fallbackFormatter, IReadOnlyCollection <IHealthOutputFormatter> formatters) { if (formatters == null) { throw new ArgumentNullException(nameof(formatters)); } _formatters = new HealthFormatterCollection(formatters.ToList()); _fallbackFormatter = fallbackFormatter; }
public void Can_remove_type() { // Arrange var formatters = new HealthFormatterCollection { new HealthStatusTextOutputFormatter() }; // Act formatters.RemoveType <HealthStatusTextOutputFormatter>(); // Assert formatters.Count.Should().Be(0); }
public HealthRoot( IHealth health, HealthOptions options, HealthFormatterCollection metricsOutputFormatters, IHealthOutputFormatter defaultMetricsOutputFormatter, IRunHealthChecks healthCheckRunner) { Options = options ?? throw new ArgumentNullException(nameof(options)); _health = health ?? throw new ArgumentNullException(nameof(health)); OutputHealthFormatters = metricsOutputFormatters ?? new HealthFormatterCollection(); DefaultOutputHealthFormatter = defaultMetricsOutputFormatter; HealthCheckRunner = healthCheckRunner; }
public void Can_remove_by_mediatype() { // Arrange var mediaType = new HealthMediaTypeValue("text", "vnd.appmetrics.health", "v1", "plain"); var formatters = new HealthFormatterCollection( new List <IHealthOutputFormatter> { new HealthStatusTextOutputFormatter() }); // Act formatters.RemoveType(mediaType); // Assert formatters.Count.Should().Be(0); }
public void Returns_default_when_attempting_to_get_type_not_added() { // Arrange var formatters = new HealthFormatterCollection { new HealthStatusJsonOutputFormatter() }; // Act var formatter = formatters.GetType <HealthStatusTextOutputFormatter>(); // Assert formatter.Should().BeNull(); }
public void Returns_default_when_attempting_to_get_type_with_mediatype_not_added() { // Arrange var mediaType = new HealthMediaTypeValue("text", "vnd.appmetrics.health", "v1", "plain"); var formatters = new HealthFormatterCollection { new HealthStatusJsonOutputFormatter() }; // Act var formatter = formatters.GetType(mediaType); // Assert formatter.Should().BeNull(); }
public void Can_get_type_passing_in_type() { // Arrange var formatters = new HealthFormatterCollection { new HealthStatusTextOutputFormatter(), new HealthStatusJsonOutputFormatter() }; // Act var formatter = formatters.GetType(typeof(HealthStatusTextOutputFormatter)); // Assert formatter.Should().NotBeNull(); formatter.Should().BeOfType <HealthStatusTextOutputFormatter>(); }
public void Can_get_by_mediatype() { // Arrange var mediaType = new HealthMediaTypeValue("application", "vnd.appmetrics.health", "v1", "json"); var formatters = new HealthFormatterCollection { new HealthStatusTextOutputFormatter(), new HealthStatusJsonOutputFormatter() }; // Act var formatter = formatters.GetType(mediaType); // Assert formatter.Should().NotBeNull(); formatter.Should().BeOfType <HealthStatusJsonOutputFormatter>(); }
public HealthEndpointsOptionsSetup(IReadOnlyCollection <IHealthOutputFormatter> healthFormatters) { _healthFormatters = new HealthFormatterCollection(healthFormatters.ToList()); }