- 上帝类减重 42 行;枚举与两个纯函数零实例状态、零 DB 依赖,符合 Accrual/ 既有纯函数迁移模式 - 测试不再继承 TestableSwapEodPositionService(原仅为够到 protected),plain 测试类 - SwapEodPositionService 两处调用点改为 InterestEodScenarioDispatch.FindObservationInterval 限定名 - 编译 0 错误;表驱动 8/8 通过
31 lines
1.9 KiB
C#
31 lines
1.9 KiB
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace YLErp.Modules.SwapModule
|
|
{
|
|
/// <summary>
|
|
/// DealInterests 分派优先级(TEST-MATRIX §6 空洞补盖)。
|
|
/// 纯函数 InterestEodScenarioDispatch.ResolveInterestScenario 的 8 组合表驱动单测,不连库、无 DB。
|
|
/// 守卫:手工互换压制观察日自动结息;观察日±平仓区分 autoSwap 真/假;纯平仓与普通日分流。
|
|
/// </summary>
|
|
[TestClass]
|
|
public class InterestEodScenarioDispatchTest
|
|
{
|
|
[DataTestMethod]
|
|
[DataRow(false, false, false, InterestEodScenario.RollForward)] // 普通日
|
|
[DataRow(false, false, true, InterestEodScenario.CloseOnly)] // 纯平仓(非观察日)
|
|
[DataRow(false, true, false, InterestEodScenario.ManualSwap)] // 手工互换(非观察日)
|
|
[DataRow(false, true, true, InterestEodScenario.ManualSwap)] // 手工互换+平仓 → 手工优先
|
|
[DataRow(true, false, false, InterestEodScenario.AutoSettle)] // 观察日, 无平仓
|
|
[DataRow(true, false, true, InterestEodScenario.AutoSettleWithClose)] // 观察日+平仓 (autoSwap=true)
|
|
[DataRow(true, true, false, InterestEodScenario.ManualSwap)] // 观察日+手工互换 → 手工优先
|
|
[DataRow(true, true, true, InterestEodScenario.ManualSwap)] // 观察日+手工互换+平仓 → 手工优先
|
|
public void ResolveInterestScenario_CoversAllEightCombinations(
|
|
bool hasInterval, bool hasSwap, bool hasClose, InterestEodScenario expected)
|
|
{
|
|
var actual = InterestEodScenarioDispatch.ResolveInterestScenario(hasInterval, hasSwap, hasClose);
|
|
Assert.AreEqual(expected, actual,
|
|
$"hasInterval={hasInterval}, hasSwap={hasSwap}, hasClose={hasClose}");
|
|
}
|
|
}
|
|
}
|