#EQD-6948 国联民生-实现保证金规则(2)追保金额的产生与收盘计算 收盘计算和授信占用
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using YLErp.BLL;
|
||||
using YLErp.DBModels;
|
||||
|
||||
namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 新建表列名规范测试(2026-08-20 约定:新建表所有数据库列一律小写下划线)。
|
||||
/// 只构建 EF 模型(纯内存,不连库),断言映射列名不含大写字母:
|
||||
/// client_credit_inout 全表、swap_position.fund_tag、credit.original_credit/max_credit_use_ratio。
|
||||
/// 基类操作人列(OptId/OptName/OptTime)经 override+[Column] 覆写为小写,此处一并守护。
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class DbColumnNamingTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void DB_001_授信出入表_全部列名小写()
|
||||
{
|
||||
using var db = new YLContext();
|
||||
var entity = db.Model.FindEntityType(typeof(client_credit_inout));
|
||||
Assert.IsNotNull(entity, "client_credit_inout 未注册到 YLContext");
|
||||
var table = StoreObjectIdentifier.Table("client_credit_inout", null);
|
||||
foreach (var property in entity.GetProperties())
|
||||
{
|
||||
var column = property.GetColumnName(table);
|
||||
Assert.IsNotNull(column, $"属性 {property.Name} 未映射列名");
|
||||
Assert.IsFalse(column.Any(char.IsUpper), $"列名应全小写: {column}(属性 {property.Name})");
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DB_002_互换持仓与授信表_新增列名小写()
|
||||
{
|
||||
using var db = new YLContext();
|
||||
AssertColumn(db, typeof(swap_position), nameof(swap_position.FundTag), "fund_tag");
|
||||
AssertColumn(db, typeof(CreditTable), nameof(CreditTable.OriginalCredit), "original_credit");
|
||||
AssertColumn(db, typeof(CreditTable), nameof(CreditTable.MaxCreditUseRatio), "max_credit_use_ratio");
|
||||
}
|
||||
|
||||
private static void AssertColumn(YLContext db, Type entityType, string propertyName, string expectedColumn)
|
||||
{
|
||||
var entity = db.Model.FindEntityType(entityType);
|
||||
Assert.IsNotNull(entity, $"{entityType.Name} 未注册到 YLContext");
|
||||
var property = entity.FindProperty(propertyName);
|
||||
Assert.IsNotNull(property, $"属性 {propertyName} 不在 {entityType.Name} 映射中");
|
||||
var table = StoreObjectIdentifier.Create(entity, StoreObjectType.Table).Value;
|
||||
var column = property.GetColumnName(table);
|
||||
Assert.AreEqual(expectedColumn, column, $"{entityType.Name}.{propertyName} 映射列名不符");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user