手动数据源、存图、流程计算

This commit is contained in:
zhengxuan.zhang
2026-05-15 15:29:53 +08:00
parent f07d891346
commit 49c6785682
9 changed files with 800 additions and 419 deletions
@@ -212,7 +212,7 @@ namespace XplorePlane.Tests.Services
var (service, mockPipelineExec, _, _, _) = CreateServiceWithCapture(detectorImage);
// Track all pipeline execution calls with their source images
var pipelineCalls = new List<(Guid NodeId, BitmapSource SourceImage)>();
var pipelineCalls = new List<BitmapSource>();
mockPipelineExec
.Setup(p => p.ExecutePipelineAsync(
@@ -223,8 +223,7 @@ namespace XplorePlane.Tests.Services
.Callback<IEnumerable<PipelineNodeViewModel>, BitmapSource, IProgress<PipelineProgress>, CancellationToken>(
(nodes, source, progress, ct) =>
{
// We can't easily get the NodeId from here, but we track the source image
pipelineCalls.Add((Guid.Empty, source));
pipelineCalls.Add(source);
})
.ReturnsAsync(detectorImage);
@@ -235,7 +234,8 @@ namespace XplorePlane.Tests.Services
var allNodesOrdered = program.Nodes.OrderBy(n => n.Index).ToList();
var savePositionNodes = allNodesOrdered.OfType<SavePositionNode>().ToList();
int expectedPipelineCalls = 0;
// Count SavePositionNodes that are immediately followed by InspectionModuleNode
int savePositionFollowedByInspection = 0;
foreach (var sp in savePositionNodes)
{
int spOrderIndex = allNodesOrdered.FindIndex(n => n.Id == sp.Id);
@@ -243,21 +243,25 @@ namespace XplorePlane.Tests.Services
{
var nextNode = allNodesOrdered[spOrderIndex + 1];
if (nextNode is InspectionModuleNode)
expectedPipelineCalls++;
savePositionFollowedByInspection++;
}
}
// Verify: pipeline was called exactly for each SavePositionNode followed by InspectionModuleNode
bool correctCallCount = pipelineCalls.Count == expectedPipelineCalls;
// Property verification:
// 1. When a SavePositionNode is followed by InspectionModuleNode, pipeline MUST be called
// at least once with the detector image (from the multi-position loop)
// 2. All pipeline calls must receive the detector image as source
// (since all images come from the same detector mock)
// Verify: each pipeline call received a non-null source image (the detector image)
bool allReceivedImage = pipelineCalls.All(c => c.SourceImage != null);
// If there are SavePositionNodes followed by InspectionModuleNodes,
// the pipeline must have been called at least that many times
bool pipelineCalledForFollowedNodes = pipelineCalls.Count >= savePositionFollowedByInspection;
// Verify: each pipeline call received the same detector image
bool allReceivedCorrectImage = pipelineCalls.All(c =>
ReferenceEquals(c.SourceImage, detectorImage));
// Every pipeline call must have received the detector image
bool allReceivedCorrectImage = pipelineCalls.All(img =>
ReferenceEquals(img, detectorImage));
return correctCallCount && allReceivedImage && allReceivedCorrectImage;
return pipelineCalledForFollowedNodes && allReceivedCorrectImage;
});
}