public async Task Context_Contains_NotChecked_Tag_When_The_Original_Check_Is_Not_Executed() { // Arrange var decoratedHealthCheckMock = new Mock <IHealthCheck>(); var sut = new ConditionalHealthCheck(() => decoratedHealthCheckMock.Object, (_, __) => Task.FromResult(false), null, null); var context = new HealthCheckContextBuilder().WithInstance(decoratedHealthCheckMock.Object) .Build(); // Act await sut.CheckHealthAsync(context); // Assert context.Registration.Tags.Should().Contain("NotChecked"); }
public async Task Result_Is_Healthy() { // Arrange var decoratedHealthCheckMock = new Mock <IHealthCheck>(); var sut = new ConditionalHealthCheck(() => decoratedHealthCheckMock.Object, (_, __) => Task.FromResult(false), null, null); var context = new HealthCheckContextBuilder().WithInstance(decoratedHealthCheckMock.Object) .Build(); // Act var result = await sut.CheckHealthAsync(context); // Assert result.Status.Should().Be(HealthStatus.Healthy); }
public async Task Result_Has_A_Meaningful_Description() { // Arrange var decoratedHealthCheckMock = new Mock <IHealthCheck>(); var sut = new ConditionalHealthCheck(() => decoratedHealthCheckMock.Object, (_, __) => Task.FromResult(false), null, null); var context = new HealthCheckContextBuilder().WithInstance(decoratedHealthCheckMock.Object) .Build(); // Act var result = await sut.CheckHealthAsync(context); // Assert result.Description.Should().Match("*`TheCheck` will not be evaluated*"); }
public async Task Logs_a_Debug_Message_When_The_Original_Health_Check_Is_Not_Executed() { // Arrange var decoratedHealthCheckMock = new Mock <IHealthCheck>(); var loggerMock = new Mock <ILogger <ConditionalHealthCheck> >(); var sut = new ConditionalHealthCheck(() => decoratedHealthCheckMock.Object, (_, __) => Task.FromResult(false), null, loggerMock.Object); var context = new HealthCheckContextBuilder().WithInstance(decoratedHealthCheckMock.Object) .Build(); // Act await sut.CheckHealthAsync(context); // Assert loggerMock.VerifyLog(logger => logger.LogDebug("HealthCheck `TheCheck` will not be executed as its checking condition is not met.")); }