using Microsoft.VisualStudio.TestTools.UnitTesting; namespace YLErp.Modules.SwapModule { /// /// DealInterests 分派优先级(TEST-MATRIX §6 空洞补盖)。 /// 纯函数 InterestEodScenarioDispatch.ResolveInterestScenario 的 8 组合表驱动单测,不连库、无 DB。 /// 守卫:手工互换压制观察日自动结息;观察日±平仓区分 autoSwap 真/假;纯平仓与普通日分流。 /// [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}"); } } }