public async Task RunAsync_GivenAResponseCustomizerThatThrows_DoesNotThrow()
        {
            var mockHealthCheck1 = new Mock <IHealthCheck>();
            var result1          = new HealthCheckResult();
            IReadOnlyList <HealthCheckResult> results1 = new[] { result1 };

            mockHealthCheck1.Setup(m => m.CheckAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult(results1));

            var mockHealthCheck2 = new Mock <IHealthCheck>();
            var result2          = new HealthCheckResult();
            IReadOnlyList <HealthCheckResult> results2 = new[] { result2 };

            mockHealthCheck2.Setup(m => m.CheckAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult(results2));

            var mockResponseCustomizer = new Mock <IHealthResponseCustomizer>();
            var exception = new Exception();

            mockResponseCustomizer.Setup(m => m.CustomizeResponse(It.IsAny <HealthResponse>())).Throws(exception);

            var healthChecks       = new[] { mockHealthCheck1.Object, mockHealthCheck2.Object };
            var responseCustomizer = mockResponseCustomizer.Object;

            var runner = new HealthCheckRunner(healthChecks, responseCustomizer: responseCustomizer);

            var response = await runner.RunAsync();

            response.GetChecks().Should().BeEquivalentTo(new[] { result1, result2 });

            mockResponseCustomizer.Verify(m => m.CustomizeResponse(It.Is <HealthResponse>(responseParam => ReferenceEquals(response, responseParam))), Times.Once);

            mockHealthCheck1.Verify(m => m.CheckAsync(It.IsAny <CancellationToken>()), Times.Once);
            mockHealthCheck2.Verify(m => m.CheckAsync(It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task RunAsync_GivenNoResponseCustomizer_DoesNotThrow()
        {
            var mockHealthCheck1 = new Mock <IHealthCheck>();
            var result1          = new HealthCheckResult();
            IReadOnlyList <HealthCheckResult> results1 = new[] { result1 };

            mockHealthCheck1.Setup(m => m.CheckAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult(results1));

            var mockHealthCheck2 = new Mock <IHealthCheck>();
            var result2          = new HealthCheckResult();
            IReadOnlyList <HealthCheckResult> results2 = new[] { result2 };

            mockHealthCheck2.Setup(m => m.CheckAsync(It.IsAny <CancellationToken>())).Returns(Task.FromResult(results2));

            var healthChecks = new[] { mockHealthCheck1.Object, mockHealthCheck2.Object };

            var runner = new HealthCheckRunner(healthChecks);

            var response = await runner.RunAsync();

            response.GetChecks().Should().BeEquivalentTo(new[] { result1, result2 });

            mockHealthCheck1.Verify(m => m.CheckAsync(It.IsAny <CancellationToken>()), Times.Once);
            mockHealthCheck2.Verify(m => m.CheckAsync(It.IsAny <CancellationToken>()), Times.Once);
        }