File size: 781 Bytes
f77358e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | using System.Net;
using Microsoft.AspNetCore.Mvc.Testing;
using Xunit;
using FluentAssertions;
namespace AiDevProject.Tests.Unit;
/// <summary>
/// Tests for health controller.
/// </summary>
public class HealthControllerTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly HttpClient _client;
public HealthControllerTests(WebApplicationFactory<Program> factory)
{
_client = factory.CreateClient();
}
[Fact]
public async Task GetHealth_ReturnsOk()
{
// Act
var response = await _client.GetAsync("/api/health");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("ok");
}
}
|