test(swap): 复利consumedInterest扣除合成测试(补c6adb3bb覆盖缺口)

c6adb3bb加的复利consumedInterest扣除此前无任何测试覆盖。
现在用4个合成测试完整验证:

改动(SwapDealService.cs):
- GetConsumedInterest加virtual关键字(测试可override注入内存值)

新增(ConsumedInterestScenarioTest.cs):
- StubSwapDealService override TryGetFloatRate+GetConsumedInterest
  (模仿T0/T1的StubSwapDealService模式)
- CI_001: 基线(consumedInterest=0)拿到全程复利利息
- CI_002: 注入consumedInterest后利息=基线-consumed(直接验证cs:793)
- CI_003: 守恒(consumed+利息=基线)×3组不同consumed值
- CI_004: 全部已结(consumed=基线)平仓≈0不为负(防双重扣减)

关键发现:测试必须传settment:false走盘中平仓路径(CalcUnwindInterest),
settment:true(默认)走收盘归档路径(CalcEodInterest)不传consumedInterest。

验证: 89(T0/T1)+7(DealInterests)+4(ConsumedInterest)=100全通过。
This commit is contained in:
hjhan
2026-07-01 18:40:48 +08:00
parent be88442c91
commit f501ee95a7
2 changed files with 251 additions and 1 deletions
@@ -347,7 +347,7 @@ namespace YLErp.Modules.SwapModule
/// <param name="positionId">利息腿id</param>
/// <param name="beforeDate">结算日(不含,仅汇总此日之前的历史已结利息;当日事件由 closeList 去重逻辑单独处理)</param>
/// <returns>历史已结利息累计金额(绝对值)</returns>
public decimal GetConsumedInterest(int tradeId, long positionId, DateTime beforeDate)
public virtual decimal GetConsumedInterest(int tradeId, long positionId, DateTime beforeDate)
{
List<int> swapEventTypes = new List<int>() { (int)SwapEventTypeEnum., (int)SwapEventTypeEnum. };
var consumed = DbContext.swap_flow_event