From 657c44b8f4b75c7920060f6fc8855dcea5a59fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Fri, 21 Aug 2026 17:28:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(test):=20=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=BA=92=E6=8D=A2=E6=B5=8B=E8=AF=95=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E4=BA=8B=E4=BB=B6=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除多余的 PersistFlowEvent 方法重写 - 更新 PersistedFlowEvents 属性实现以直接使用 FlowEvents - 添加详细注释说明测试接缝的设计意图 - 简化测试代码结构提高可维护性 --- .../SwapModule/BondTrsAutoSwapScenarioTest.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/UnitTestProject/Modules/SwapModule/BondTrsAutoSwapScenarioTest.cs b/UnitTestProject/Modules/SwapModule/BondTrsAutoSwapScenarioTest.cs index 35aac0b8..abed4ca8 100644 --- a/UnitTestProject/Modules/SwapModule/BondTrsAutoSwapScenarioTest.cs +++ b/UnitTestProject/Modules/SwapModule/BondTrsAutoSwapScenarioTest.cs @@ -68,8 +68,11 @@ namespace YLErp.Modules.SwapModule /// 捕获生成的自动互换主事件(EventType=自动互换) public List<(DateTime valueDate, int eventType, string reason, UnwindData data)> SwapEvents { get; } = new(); - /// 捕获落库的互换流水明细 - public List PersistedFlowEvents => DbContext.swap_flow_event.Local.ToList(); + /// + /// 捕获自动互换生成的流水明细。父测试替身的 PersistFlowEvent 只写入 + /// FlowEvents,不会写入 EF 的 Local 集合,因此断言必须复用该测试接缝。 + /// + public List PersistedFlowEvents => FlowEvents; /// 捕获资金流水的金额、操作类型和发生日 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 }; } - /// - /// 捕获 SaveAutoSwapDeal 落库的 flow_event(生产写 DbContext.swap_flow_event)。 - /// 同步到 PersistedFlowEvents 供 AS_009/010/011 断言;基类 FlowEvents 仍由它填充, - /// 供 GetConsumedInterest 真实计算已结利息。 - /// - protected override void PersistFlowEvent(swap_flow_event flowEvent) - { - base.PersistFlowEvent(flowEvent); - PersistedFlowEvents.Add(flowEvent); - } - /// /// 利息腿金额直接给定(付息金额),避免把 GetInterests 的计息细节混入本用例—— /// 本文件关注的是「自动互换是否触发 / 几条 / 资金发生日 / 金额量级」,