You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
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 ) ;
}
}
}