refactor(swap-eod): L0 纯函数出仓——InterestEodScenario/ResolveInterestScenario/FindObservationInterval 移至独立 InterestEodScenarioDispatch(零行为变更)

- 上帝类减重 42 行;枚举与两个纯函数零实例状态、零 DB 依赖,符合 Accrual/ 既有纯函数迁移模式
- 测试不再继承 TestableSwapEodPositionService(原仅为够到 protected),plain 测试类
- SwapEodPositionService 两处调用点改为 InterestEodScenarioDispatch.FindObservationInterval 限定名
- 编译 0 错误;表驱动 8/8 通过
This commit is contained in:
hjhan
2026-08-17 17:36:41 +08:00
parent ec9c493420
commit 9ae2e66b75
3 changed files with 52 additions and 47 deletions
@@ -4,15 +4,12 @@ namespace YLErp.Modules.SwapModule
{
/// <summary>
/// DealInterests 分派优先级(TEST-MATRIX §6 空洞补盖)。
/// 纯函数 ResolveInterestScenario 的 8 组合表驱动单测,不连库、无 DB。
/// 纯函数 InterestEodScenarioDispatch.ResolveInterestScenario 的 8 组合表驱动单测,不连库、无 DB。
/// 守卫:手工互换压制观察日自动结息;观察日±平仓区分 autoSwap 真/假;纯平仓与普通日分流。
/// 测试类直接继承 TestableSwapEodPositionService 以访问 protected 的枚举与方法。
/// </summary>
[TestClass]
public class InterestEodScenarioDispatchTest : TestableSwapEodPositionService
public class InterestEodScenarioDispatchTest
{
public InterestEodScenarioDispatchTest() : base(nameof(InterestEodScenarioDispatchTest)) { }
[DataTestMethod]
[DataRow(false, false, false, InterestEodScenario.RollForward)] // 普通日
[DataRow(false, false, true, InterestEodScenario.CloseOnly)] // 纯平仓(非观察日)
@@ -25,7 +22,7 @@ namespace YLErp.Modules.SwapModule
public void ResolveInterestScenario_CoversAllEightCombinations(
bool hasInterval, bool hasSwap, bool hasClose, InterestEodScenario expected)
{
var actual = ResolveInterestScenario(hasInterval, hasSwap, hasClose);
var actual = InterestEodScenarioDispatch.ResolveInterestScenario(hasInterval, hasSwap, hasClose);
Assert.AreEqual(expected, actual,
$"hasInterval={hasInterval}, hasSwap={hasSwap}, hasClose={hasClose}");
}