#region ========================================================================= USING =====================================================================================
using Nemera.Presentation.Web.Fixtures.Common.TestHelpers;
using Nemera.Presentation.Web.IntegrationTests.Common.Setup;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
#endregion
namespace Nemera.Presentation.Web.IntegrationTests.Core.Health;
///
/// Contains integration tests for the /health/ready probe route when the API is unreachable.
///
[ExcludeFromCodeCoverage]
public class HealthEndpointFailureTests : IClassFixture
{
private readonly FailingApiHealthFactory _apiFactory;
///
/// Initializes a new instance of the class.
///
/// Injected Web application factory with a failing API reachability check.
public HealthEndpointFailureTests(FailingApiHealthFactory apiFactory)
{
_apiFactory = apiFactory;
}
[Fact]
public async Task HealthReady_WhenApiIsUnreachable_ShouldReturnServiceUnavailable()
{
// Arrange
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
// Act
HttpResponseMessage response = await client.GetAsync("/health/ready");
// Assert
Assert.Equal(HttpStatusCode.ServiceUnavailable, response.StatusCode);
}
}