public async Task CheckAsync_ReturnsOneResult() { var healthCheck = new TestHealthCheck(); var result = await healthCheck.CheckAsync(); result.Should().HaveCount(1); result[0]["fake"].Should().Be(true); }
public void Constructor_SetsProperties() { var healthCheck = new TestHealthCheck("FakeComponentName", "FakeMeasurementName", "FakeComponentType", "FakeComponentId"); healthCheck.ComponentName.Should().Be("FakeComponentName"); healthCheck.MeasurementName.Should().Be("FakeMeasurementName"); healthCheck.ComponentType.Should().Be("FakeComponentType"); healthCheck.ComponentId.Should().Be("FakeComponentId"); }
public void AddCheck_T_Service() { // Arrange var instance = new TestHealthCheck(); var services = CreateServices(); services.AddSingleton(instance); services.AddHealthChecks().AddCheck<TestHealthCheck>("test", failureStatus: HealthStatus.Degraded, tags: new[] { "tag", }); var serviceProvider = services.BuildServiceProvider(); // Act var options = serviceProvider.GetRequiredService<IOptions<HealthCheckServiceOptions>>().Value; // Assert var registration = Assert.Single(options.Registrations); Assert.Equal("test", registration.Name); Assert.Equal(HealthStatus.Degraded, registration.FailureStatus); Assert.Equal<string>(new[] { "tag", }, registration.Tags); Assert.Same(instance, registration.Factory(serviceProvider)); }