public async Task ReadAllHealthReports() { Uri tableRequestUri = null; void SaveRequest(HttpRequestMessage tableReplaceRequest) { tableRequestUri = tableReplaceRequest.RequestUri; } var handler = new MockHandler(req => { SaveRequest(req); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent( @"{""value"":[ {""PartitionKey"":""Microsoft.DotNet.Internal.Health.Tests.HealthReportingTests"", ""RowKey"":""TEST-INSTANCE|TEST-SUB-STATUS-INSTANCE"", ""Timestamp"":""2001-02-03T16:05:06.007Z"", ""Status"":""Healthy"", ""Message"":""TEST SUB-STATUS MESSAGES""}, {""PartitionKey"":""Microsoft.DotNet.Internal.Health.Tests.HealthReportingTests"", ""RowKey"":""|TEST-SUB-STATUS-SERVICE"", ""Timestamp"":""2001-02-03T17:05:06.007Z"", ""Status"":""Error"", ""Message"":""TEST STATUS MESSAGES""} ]}") { Headers = { ContentType = MediaTypeHeaderValue.Parse("application/json") } } }; return(Task.FromResult(response)); }); await using ServiceProvider services = BuildServiceProvider(handler); var provider = services.GetRequiredService <IHealthReportProvider>(); var report = await provider.GetAllStatusAsync(GetType().FullName); report.Should().HaveCount(2); { report.FirstOrDefault(r => r.Instance != null).Should().NotBeNull(); var instanceReport = report.FirstOrDefault(r => r.Instance != null); instanceReport.Service.Should().Be(GetType().FullName); instanceReport.Instance.Should().Be("TEST-INSTANCE"); instanceReport.Message.Should().Be("TEST SUB-STATUS MESSAGES"); instanceReport.Health.Should().Be(HealthStatus.Healthy); instanceReport.SubStatus.Should().Be("TEST-SUB-STATUS-INSTANCE"); instanceReport.AsOf.Should().Be(new DateTimeOffset(2001, 2, 3, 16, 5, 6, 7, TimeSpan.Zero)); } { report.FirstOrDefault(r => r.Instance == null).Should().NotBeNull(); var serviceReport = report.FirstOrDefault(r => r.Instance == null); serviceReport.Service.Should().Be(GetType().FullName); serviceReport.Message.Should().Be("TEST STATUS MESSAGES"); serviceReport.Health.Should().Be(HealthStatus.Error); serviceReport.SubStatus.Should().Be("TEST-SUB-STATUS-SERVICE"); serviceReport.AsOf.Should().Be(new DateTimeOffset(2001, 2, 3, 17, 5, 6, 7, TimeSpan.Zero)); } }