using System.Web.Http.Results;
using CncWebApi.Controllers;
using Xunit;

namespace CncWebApi.Tests
{
    /// <summary>
    /// HealthController单元测试
    /// 健康检查接口，无依赖，无JWT过滤
    /// </summary>
    [Collection("Database")]
    public class HealthControllerTests
    {
        private readonly HealthController _controller;

        public HealthControllerTests()
        {
            _controller = ControllerFactory.CreateHealthController();
        }

        /// <summary>
        /// 测试：健康检查返回正常状态
        /// Controller返回匿名类型，通过反射验证Content
        /// </summary>
        [Fact]
        public void Check_ShouldReturnHealthy()
        {
            // Act
            var result = _controller.Check();

            // Assert - OkNegotiatedContentResult<T>有Content属性
            Assert.NotNull(result);
            var content = result.GetType().GetProperty("Content")?.GetValue(result);
            Assert.NotNull(content);
        }
    }
}
