public async Task ShouldGetHealthyAsync() { _repositoryHealthCheck = new Mock <IRepositoryHealthCheck>(); _persistenceLayerHealthCheck = new PersistenceLayerHealthCheck(_repositoryHealthCheck.Object, _logger.Object); var context = new HealthCheckContext(); var cancelToken = new CancellationToken(); var result = (await _persistenceLayerHealthCheck.CheckHealthAsync(context, cancelToken).ConfigureAwait(false)); result.Status.Should().Be(2); }
public async Task ShouldGetUnhealthyAsync() { _repositoryHealthCheck = new Mock <IRepositoryHealthCheck>(MockBehavior.Strict); _repositoryHealthCheck.Setup(x => x.RunAsync(new CancellationToken())).ThrowsAsync(new IOException()); _persistenceLayerHealthCheck = new PersistenceLayerHealthCheck(_repositoryHealthCheck.Object, _logger.Object); var context = new HealthCheckContext() { Registration = new HealthCheckRegistration("Test", _persistenceLayerHealthCheck, HealthStatus.Unhealthy, new List <string>()) }; var cancelToken = new CancellationToken(); var result = (await _persistenceLayerHealthCheck.CheckHealthAsync(context, cancelToken).ConfigureAwait(false)); result.Status.Should().Be(0); result.Exception.Message.Should().Be(new IOException().Message); }