コード例 #1
0
        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");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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*");
        }
コード例 #4
0
        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."));
        }