Пример #1
0
        public async Task should_return_error_status_code_if_db_connection_fails()
        {
            var connectResult = new DbHealthCheckResult {
                CanConnect = false
            };

            _queryHandlerMock
            .Setup(x => x.Handle <DbHealthCheckQuery, DbHealthCheckResult>(It.IsAny <DbHealthCheckQuery>()))
            .ReturnsAsync(connectResult);

            var result = await _controller.HealthAsync();

            result.Should().BeOfType <ObjectResult>();
            var typedResult = (ObjectResult)result;
            var response    = (HealthResponse)typedResult.Value;

            response.AppVersion.FileVersion.Should().NotBeNullOrWhiteSpace();
            response.AppVersion.InformationVersion.Should().NotBeNullOrWhiteSpace();
            response.DatabaseHealth.Successful.Should().BeFalse();
        }
Пример #2
0
        public async Task Should_return_the_user_api_health()
        {
            var connectResult = new DbHealthCheckResult {
                CanConnect = true
            };

            _queryHandlerMock
            .Setup(x => x.Handle <DbHealthCheckQuery, DbHealthCheckResult>(It.IsAny <DbHealthCheckQuery>()))
            .ReturnsAsync(connectResult);

            var result = await _controller.HealthAsync();

            result.Should().BeOfType <OkObjectResult>();
            var typedResult = (OkObjectResult)result;
            var response    = (HealthResponse)typedResult.Value;

            response.AppVersion.FileVersion.Should().NotBeNullOrWhiteSpace();
            response.AppVersion.InformationVersion.Should().NotBeNullOrWhiteSpace();
            response.DatabaseHealth.Successful.Should().BeTrue();
        }