| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Admin.NET.Plugin.AiDOP.Service.S8;
- using Xunit;
- namespace Admin.NET.Test.S8;
- /// <summary>
- /// N-2 孤立审批实例告警的纯逻辑回归。
- /// 仅覆盖 payload→flowInstanceId 解析路径;SqlSugar 查询路径走 run-once 端到端验证。
- /// </summary>
- public class S8ActiveFlowWatchServiceTests
- {
- [Fact]
- public void TryExtractFlowInstanceId_Returns_Id_For_Valid_Payload()
- {
- var payload = """{"type":"S8_ORPHAN_FLOW_INSTANCE","flowInstanceId":796332066504773,"bizType":"EXCEPTION_ESCALATION"}""";
- var id = S8ActiveFlowWatchService.TryExtractFlowInstanceId(payload);
- Assert.Equal(796332066504773L, id);
- }
- [Fact]
- public void TryExtractFlowInstanceId_Returns_Null_When_Field_Missing()
- {
- var payload = """{"type":"S8_ACTIVE_FLOW_STUCK","exceptionId":42}""";
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId(payload));
- }
- [Fact]
- public void TryExtractFlowInstanceId_Returns_Null_When_Field_Wrong_Type()
- {
- var payload = """{"flowInstanceId":"not-a-number"}""";
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId(payload));
- }
- [Fact]
- public void TryExtractFlowInstanceId_Returns_Null_For_Invalid_Json()
- {
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId("{not json"));
- }
- [Fact]
- public void TryExtractFlowInstanceId_Returns_Null_For_Null_Or_Empty()
- {
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId(null));
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId(""));
- Assert.Null(S8ActiveFlowWatchService.TryExtractFlowInstanceId(" "));
- }
- }
|