- MarginModes.All/ForLinq/FixedAmountAndMargin 改为由框架常量 ConsTrade.InterestMarginModels 派生,消除 DAL 层独立重写集合(单一真源在 Core 层,本类退化为形态包装,避免新增保证金形态时口径分裂) - SwapEodPositionService.premiumModes 局部 new List 字面量替换为 MarginModes.ForLinq(DAL 内部冗余副本消除) - 重写 MarginModes.cs 过时的“复制 6 次/待收敛”注释,改为记录依赖方向与收敛历史;ForLinq 注释改为“派生自框架常量,仅做形态适配” - 更新 MarginModesTest 类注释与一致性测试注释以反映派生关系 - 验证:YLErpDAL/UnitTestProject 编译 0 错误;MarginModesTest 5/5 通过
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using YLErp.DBModels;
|
|
using YLErp.Modules.SwapModule.Margin;
|
|
|
|
namespace UnitTestProject.Modules.SwapModule.Margin
|
|
{
|
|
/// <summary>
|
|
/// MarginModes 统一判断口径测试。
|
|
/// 验证 MarginModes 由框架常量 ConsTrade.InterestMarginModels 派生,内容一致。
|
|
/// </summary>
|
|
[TestClass]
|
|
public class MarginModesTest
|
|
{
|
|
[TestMethod]
|
|
public void All_只含初始预付金和追加预付金()
|
|
{
|
|
CollectionAssert.AreEquivalent(
|
|
new[] { (int)InterestModeEnum.初始预付金, (int)InterestModeEnum.追加预付金 },
|
|
MarginModes.All.ToList());
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Contains_初始预付金_返回true()
|
|
=> Assert.IsTrue(MarginModes.Contains((int)InterestModeEnum.初始预付金));
|
|
|
|
[TestMethod]
|
|
public void Contains_追加预付金_返回true()
|
|
=> Assert.IsTrue(MarginModes.Contains((int)InterestModeEnum.追加预付金));
|
|
|
|
[TestMethod]
|
|
public void Contains_融资腿mode_返回false()
|
|
{
|
|
Assert.IsFalse(MarginModes.Contains((int)InterestModeEnum.固定值));
|
|
Assert.IsFalse(MarginModes.Contains((int)InterestModeEnum.合约名义本金规模));
|
|
Assert.IsFalse(MarginModes.Contains((int)InterestModeEnum.标的期初全价));
|
|
}
|
|
|
|
/// <summary>回归护栏:MarginModes 由 ConsTrade.InterestMarginModels 派生,内容须一致(防止有人又独立重写集合导致口径分裂)。</summary>
|
|
[TestMethod]
|
|
public void 与ConsTradeInterestMarginModels内容一致()
|
|
{
|
|
var consTrade = new List<int> { (int)InterestModeEnum.初始预付金, (int)InterestModeEnum.追加预付金 };
|
|
CollectionAssert.AreEquivalent(consTrade, MarginModes.All.ToList());
|
|
}
|
|
}
|
|
}
|