Exemplo n.º 1
0
        public async Task WithinToleranceTest()
        {
            var fixture = new TimerHealthCheckTestFixture();

            fixture.TestDateTimeServiceProvider.SetCurrentDateTimeOffSet(new DateTimeOffset(2020, 6, 23, 9, 5, 0, TimeSpan.Zero));
            fixture.SetLastCompletedTime(new DateTimeOffset(2020, 6, 23, 8, 0, 0, TimeSpan.Zero));

            var result = await fixture.HealthCheck.CheckHealthAsync(new HealthCheckContext());

            result.Status.Should().Be(HealthStatus.Healthy);
        }
Exemplo n.º 2
0
        public async Task OutsideToleranceTest()
        {
            var fixture = new TimerHealthCheckTestFixture();

            fixture.TestDateTimeServiceProvider.SetCurrentDateTimeOffSet(new DateTimeOffset(2020, 11, 23, 9, 5, 1, TimeSpan.Zero));
            fixture.SetLastCompletedTime(new DateTimeOffset(2020, 11, 23, 8, 0, 0, TimeSpan.Zero));

            var result = await fixture.HealthCheck.CheckHealthAsync(new HealthCheckContext());

            result.Status.Should().Be(HealthStatus.Unhealthy);
            result.Description.Should().Be("Timer TimerFriendlyName did not fire on time - LastCompletedTime = 11/23/2020 08:00:00 +00:00 Last Expected Time = 11/23/2020 09:00:00 +00:00\n");
        }