ai-dev-template / csharp /tests /Unit /HealthControllerTests.cs
Jordandevlog's picture
Upload csharp/tests/Unit/HealthControllerTests.cs
f77358e verified
Raw
History Blame Contribute Delete
781 Bytes
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");
}
}