public async Task WhenEventHubLoggingIsHealthy_ThenReturnsHealthy() { A.CallTo(() => fakeEventHubLoggingHealthClient.CheckHealthAsync(A <HealthCheckContext> .Ignored, A <CancellationToken> .Ignored)).Returns(new HealthCheckResult(HealthStatus.Healthy)); var response = await eventHubLoggingHealthCheck.CheckHealthAsync(new HealthCheckContext()); Assert.AreEqual(HealthStatus.Healthy, response.Status); }
public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { var healthCheckResult = await eventHubLoggingHealthClient.CheckHealthAsync(context); if (healthCheckResult.Status == HealthStatus.Healthy) { logger.LogDebug(EventIds.EventHubLoggingIsHealthy.ToEventId(), "Event hub is healthy"); } else { logger.LogError(EventIds.EventHubLoggingIsUnhealthy.ToEventId(), healthCheckResult.Exception, "Event hub is unhealthy responded with error {Message}", healthCheckResult.Exception.Message); } return(healthCheckResult); }