Resolve all 46 low-severity architecture review findings
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Debugging;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Debugging;
|
||||
|
||||
public class FlowEnumContractTests
|
||||
{
|
||||
[Fact]
|
||||
public void EnumNamesAndValues_RemainStable()
|
||||
{
|
||||
Assert.Equal(new[] { "Central", "Site", "Tags", "External" }, Enum.GetNames<FlowLane>());
|
||||
Assert.Equal(Enumerable.Range(0, 4), Enum.GetValues<FlowLane>().Select(x => (int)x));
|
||||
Assert.Equal(new[] { "InboundRequest", "RouteCall", "ScriptRun", "AttributeWrite", "AttributeWait", "Response", "ApiCall", "DbCall", "Notify", "Unknown" }, Enum.GetNames<FlowStepKind>());
|
||||
Assert.Equal(Enumerable.Range(0, 10), Enum.GetValues<FlowStepKind>().Select(x => (int)x));
|
||||
Assert.Equal(new[] { "Ok", "Failed", "TimedOut", "Predicted", "NotTraced", "Pending", "Parked" }, Enum.GetNames<FlowStepOutcome>());
|
||||
Assert.Equal(Enumerable.Range(0, 7), Enum.GetValues<FlowStepOutcome>().Select(x => (int)x));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KindRank_UsesDisplayOrderIndependentOfEnumValue()
|
||||
{
|
||||
Assert.Equal(new[] { 0, 1, 2, 3, 4, 9, 5, 5, 5, 6 }, Enum.GetValues<FlowStepKind>().Select(FlowGraphBuilder.KindRank));
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,35 @@ public class FlowGraphBuilderTests
|
||||
return [inbound, route, wait, run, write2, write1, cascade];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InferredDeviceCascade_IsDashed()
|
||||
{
|
||||
var parent = ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.AttributeWrite,
|
||||
AuditStatus.Delivered, executionId: Root);
|
||||
var child = ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.ScriptRun,
|
||||
AuditStatus.Delivered, executionId: SiteRun, parentExecutionId: Root,
|
||||
extra: new ScriptTraceExtra { TriggerSource = "inferred-device-update" }.ToJson());
|
||||
var edge = Assert.Single(FlowGraphBuilder.Build([parent, child]).Edges);
|
||||
Assert.True(edge.Spawn);
|
||||
Assert.True(edge.External);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, "terminal stack")]
|
||||
[InlineData("old stack", null)]
|
||||
public void Fold_UsesLatestErrorDetail(string? initialDetail, string? finalDetail)
|
||||
{
|
||||
var correlation = Guid.NewGuid();
|
||||
var first = ScadaBridgeAuditEventFactory.Create(AuditChannel.ApiOutbound, AuditKind.CachedSubmit,
|
||||
AuditStatus.Submitted, occurredAtUtc: T0, correlationId: correlation, errorDetail: initialDetail);
|
||||
var last = ScadaBridgeAuditEventFactory.Create(AuditChannel.ApiOutbound, AuditKind.CachedResolve,
|
||||
AuditStatus.Failed, occurredAtUtc: T0.AddSeconds(1), correlationId: correlation, errorDetail: finalDetail);
|
||||
var step = Assert.Single(FlowGraphBuilder.Build([first, last]).Steps);
|
||||
Assert.Equal(finalDetail, step.ErrorDetail);
|
||||
Assert.Equal(initialDetail, step.Lifecycle![0].ErrorDetail);
|
||||
Assert.Equal(finalDetail, step.Lifecycle[1].ErrorDetail);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DelmiaShape_ProjectsLanes_Edges_AndSynthesizedResponse()
|
||||
{
|
||||
@@ -90,6 +119,7 @@ public class FlowGraphBuilderTests
|
||||
var external = Assert.Single(graph.Edges, e => e.External);
|
||||
Assert.Equal(graph.Steps[3].EventId, external.FromEventId);
|
||||
Assert.Equal(graph.Steps[4].EventId, external.ToEventId);
|
||||
Assert.Equal(graph.Edges.Count, graph.Edges.Select(e => (e.FromEventId, e.ToEventId)).Distinct().Count());
|
||||
|
||||
// The cascade run hangs off the write that spawned it (same site, no boundary) — a Spawn edge (D9);
|
||||
// the route → run edge and every in-chain edge are not.
|
||||
|
||||
Reference in New Issue
Block a user