refactor(swap-test): 抽取 TestableSwapEodPositionService 公共基类收敛重复 Stub

- 新建 TestableSwapEodPositionService 收敛 8/8 Stub 重复的高频 override
  (PersistEodSwapPosition/SaveAllChanges/GetCurrencyRate/AddClientCash)
  + 统一 OptUserInfo 构造 + PersistedPositions/SaveChangesCount 输出捕获
- SwapEodPositionService.DealInterests 改 protected virtual(行为零变化)
- 8 个 ScenarioTest 改为继承基类,删除重复 override
- 消灭 DealInterestsScenarioTest/DealInterestsGoldenReplayTest 的反射调用
  (typeof().GetMethod().Invoke → 直接调用 DealInterests)

验证:dotnet build 0 错误;dotnet test SwapModule 284通过/6跳过/0失败
This commit is contained in:
hjhan
2026-07-23 11:16:11 +08:00
parent 63d9decd17
commit 7b007bddfa
10 changed files with 109 additions and 109 deletions
@@ -40,11 +40,11 @@ namespace YLErp.Modules.SwapModule
/// CalcBondPayment 改为按天数 × 持仓线性函数,使 TdPosiDividend 真实随
/// "天数 × 剩余持仓"变化——这是验证多日递推守恒的前提。
/// </summary>
private sealed class StubEodService : SwapEodPositionService
private sealed class StubEodService : TestableSwapEodPositionService
{
private readonly decimal _dailyRatePerUnit;
public StubEodService(decimal dailyRatePerUnit) : base(new OptUserInfo(0, nameof(MultiUnwindDividendConservationTest), OptUserFrom.UnitTest))
public StubEodService(decimal dailyRatePerUnit) : base(nameof(MultiUnwindDividendConservationTest))
{
_dailyRatePerUnit = dailyRatePerUnit;
}
@@ -66,14 +66,6 @@ namespace YLErp.Modules.SwapModule
return 1.00m;
}
protected override void SaveAllChanges() { }
// 注意:UpdateEodPosition.cs:1645 直接 new EodCurrencyRateService,不走此 seam
// 但 trade.QuoteCurrency == trade.SettlementCurrency == "CNY" 时,
// EodCurrencyRateService.GetEodCurrencyRate 会在查库前短路返回 Rate=1cs:268-281
protected override double GetCurrencyRate(string quoteCurrency, string settlementCurrency, DateTime valueDate, bool seekPreday, CurrencyRateType currencyRateType)
=> 1.0;
// 暴露 protected UpdateEodPosition(参考 GLMS20260105GoldenTest.ReplayStubService:244
public eod_swap_position ExecuteUpdateEodPosition(
swap_position swapPosition, eod_swap_position eod, trade td,