using System.Web.Http.Results;
using CncWebApi.Controllers;
using Xunit;
namespace CncWebApi.Tests
{
///
/// HealthController单元测试
/// 健康检查接口,无依赖,无JWT过滤
///
[Collection("Database")]
public class HealthControllerTests
{
private readonly HealthController _controller;
public HealthControllerTests()
{
_controller = ControllerFactory.CreateHealthController();
}
///
/// 测试:健康检查返回正常状态
/// Controller返回匿名类型,通过反射验证Content
///
[Fact]
public void Check_ShouldReturnHealthy()
{
// Act
var result = _controller.Check();
// Assert - OkNegotiatedContentResult有Content属性
Assert.NotNull(result);
var content = result.GetType().GetProperty("Content")?.GetValue(result);
Assert.NotNull(content);
}
}
}