refactor(test): 优化自动互换测试中的流水事件持久化逻辑

- 移除多余的 PersistFlowEvent 方法重写
- 更新 PersistedFlowEvents 属性实现以直接使用 FlowEvents
- 添加详细注释说明测试接缝的设计意图
- 简化测试代码结构提高可维护性
This commit is contained in:
张名锐
2026-08-21 17:28:09 +08:00
parent fa63d4ee69
commit 657c44b8f4
@@ -68,8 +68,11 @@ namespace YLErp.Modules.SwapModule
/// <summary>捕获生成的自动互换主事件(EventType=自动互换)</summary>
public List<(DateTime valueDate, int eventType, string reason, UnwindData data)> SwapEvents { get; } = new();
/// <summary>捕获落库的互换流水明细</summary>
public List<swap_flow_event> PersistedFlowEvents => DbContext.swap_flow_event.Local.ToList();
/// <summary>
/// 捕获自动互换生成的流水明细。父测试替身的 PersistFlowEvent 只写入
/// FlowEvents,不会写入 EF 的 Local 集合,因此断言必须复用该测试接缝。
/// </summary>
public List<swap_flow_event> PersistedFlowEvents => FlowEvents;
/// <summary>捕获资金流水的金额、操作类型和发生日</summary>
public List<(double amount, string action, DateTime valueDate)> ClientCashCallDetails { get; } = new();
@@ -134,17 +137,6 @@ namespace YLErp.Modules.SwapModule
return new swap_event { id = SwapEvents.Count };
}
/// <summary>
/// 捕获 SaveAutoSwapDeal 落库的 flow_event(生产写 DbContext.swap_flow_event)。
/// 同步到 PersistedFlowEvents 供 AS_009/010/011 断言;基类 FlowEvents 仍由它填充,
/// 供 GetConsumedInterest 真实计算已结利息。
/// </summary>
protected override void PersistFlowEvent(swap_flow_event flowEvent)
{
base.PersistFlowEvent(flowEvent);
PersistedFlowEvents.Add(flowEvent);
}
/// <summary>
/// 利息腿金额直接给定(付息金额),避免把 GetInterests 的计息细节混入本用例——
/// 本文件关注的是「自动互换是否触发 / 几条 / 资金发生日 / 金额量级」,