25 lines
810 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BuildFlow.Shared.Domain.Common;
namespace BuildFlow.SSO.Tests;
/// <summary>测试辅助扩展。填充审计字段(含 IHasOperatorIP)为默认值。</summary>
public static class TestExtensions
{
/// <summary>填充实体的全部审计字段(IAuditable + IHasOperatorIP),测试用。</summary>
public static T FillAudit<T>(this T entity) where T : IAuditable
{
entity.CreatedBy = "test";
entity.CreatedAt = DateTime.UtcNow;
entity.UpdatedBy = "test";
entity.UpdatedAt = DateTime.UtcNow;
// IHasOperatorIP 也需要填充(Role 实现了 IFullAudit = IAuditable + ISoftDelete + IHasOperatorIP)
if (entity is IHasOperatorIP hasIp)
{
hasIp.OperatorIP = "127.0.0.1";
}
return entity;
}
}