Plan 用于 CNC 默认保存和加载,Tools 用于流程图配方 xpm,Data 用于执行结果和中间图像,Report 为报告预留目录
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Windows.Media.Imaging;
|
||||
using XP.Common.Logging.Interfaces;
|
||||
using XplorePlane.Models;
|
||||
using XplorePlane.Services;
|
||||
using XplorePlane.Services.Storage;
|
||||
using XplorePlane.Tests.Helpers;
|
||||
using XplorePlane.ViewModels;
|
||||
using Xunit;
|
||||
@@ -22,6 +23,7 @@ namespace XplorePlane.Tests.Pipeline
|
||||
private readonly Mock<IPipelineExecutionService> _mockExecSvc;
|
||||
private readonly Mock<IPipelinePersistenceService> _mockPersistSvc;
|
||||
private readonly Mock<ILoggerService> _mockLogger;
|
||||
private readonly Mock<IXpDataPathService> _mockDataPathService;
|
||||
|
||||
public PipelineEditorViewModelTests()
|
||||
{
|
||||
@@ -29,11 +31,19 @@ namespace XplorePlane.Tests.Pipeline
|
||||
_mockExecSvc = new Mock<IPipelineExecutionService>();
|
||||
_mockPersistSvc = new Mock<IPipelinePersistenceService>();
|
||||
_mockLogger = new Mock<ILoggerService>();
|
||||
_mockDataPathService = new Mock<IXpDataPathService>();
|
||||
_mockLogger.Setup(l => l.ForModule<PipelineEditorViewModel>()).Returns(_mockLogger.Object);
|
||||
_mockDataPathService.SetupGet(s => s.ToolsPath).Returns(Path.GetTempPath());
|
||||
}
|
||||
|
||||
private PipelineEditorViewModel CreateVm() =>
|
||||
new PipelineEditorViewModel(_mockImageSvc.Object, _mockExecSvc.Object, _mockPersistSvc.Object, new EventAggregator(), _mockLogger.Object);
|
||||
new PipelineEditorViewModel(
|
||||
_mockImageSvc.Object,
|
||||
_mockExecSvc.Object,
|
||||
_mockPersistSvc.Object,
|
||||
new EventAggregator(),
|
||||
_mockLogger.Object,
|
||||
_mockDataPathService.Object);
|
||||
|
||||
// ── 6.1 AddOperatorCommand ────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using XplorePlane.Models;
|
||||
using XplorePlane.Services;
|
||||
using XplorePlane.Services.Storage;
|
||||
using XplorePlane.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
@@ -199,5 +201,21 @@ namespace XplorePlane.Tests.Pipeline
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LoadAllAsync_UsesToolsPath_WhenConstructedWithDataPathService()
|
||||
{
|
||||
var mockImageSvc = TestHelpers.CreateMockImageService(new[] { "Blur" });
|
||||
var mockDataPathSvc = new Mock<IXpDataPathService>();
|
||||
mockDataPathSvc.SetupGet(s => s.ToolsPath).Returns(_tempDir);
|
||||
|
||||
var service = new PipelinePersistenceService(mockImageSvc.Object, mockDataPathSvc.Object);
|
||||
await service.SaveAsync(BuildModel("P3", "Blur"), Path.Combine(_tempDir, "p3.xpm"));
|
||||
|
||||
var result = await service.LoadAllAsync(null);
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal("P3", result[0].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using XP.Common.Logging.Interfaces;
|
||||
using XplorePlane.Models;
|
||||
using XplorePlane.Services;
|
||||
using XplorePlane.Services.Storage;
|
||||
using XplorePlane.Tests.Helpers;
|
||||
using XplorePlane.ViewModels;
|
||||
|
||||
@@ -31,8 +32,16 @@ namespace XplorePlane.Tests.Pipeline
|
||||
var mockExecSvc = new Mock<IPipelineExecutionService>();
|
||||
var mockPersistSvc = new Mock<IPipelinePersistenceService>();
|
||||
var mockLogger = new Mock<ILoggerService>();
|
||||
var mockDataPathService = new Mock<IXpDataPathService>();
|
||||
mockLogger.Setup(l => l.ForModule<PipelineEditorViewModel>()).Returns(mockLogger.Object);
|
||||
return new PipelineEditorViewModel(mockImageSvc.Object, mockExecSvc.Object, mockPersistSvc.Object, new EventAggregator(), mockLogger.Object);
|
||||
mockDataPathService.SetupGet(s => s.ToolsPath).Returns(Path.GetTempPath());
|
||||
return new PipelineEditorViewModel(
|
||||
mockImageSvc.Object,
|
||||
mockExecSvc.Object,
|
||||
mockPersistSvc.Object,
|
||||
new EventAggregator(),
|
||||
mockLogger.Object,
|
||||
mockDataPathService.Object);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,6 +11,7 @@ using XP.Common.Database.Interfaces;
|
||||
using XP.Common.Logging.Interfaces;
|
||||
using XplorePlane.Models;
|
||||
using XplorePlane.Services.InspectionResults;
|
||||
using XplorePlane.Services.Storage;
|
||||
using Xunit;
|
||||
|
||||
namespace XplorePlane.Tests.Services
|
||||
@@ -294,6 +295,33 @@ namespace XplorePlane.Tests.Services
|
||||
Assert.Equal(originalHash, snapshot.PipelineHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Constructor_WithDataPathService_WritesIntoDataInspectionResultsDirectory()
|
||||
{
|
||||
var mockDataPathService = new Mock<IXpDataPathService>();
|
||||
var dataRoot = Path.Combine(_tempRoot, "xpdata", "Data");
|
||||
mockDataPathService.SetupGet(s => s.DataPath).Returns(dataRoot);
|
||||
|
||||
var store = new InspectionResultStore(_dbContext, _mockLogger.Object, mockDataPathService.Object);
|
||||
var run = new InspectionRunRecord
|
||||
{
|
||||
ProgramName = "Program-By-Service",
|
||||
WorkpieceId = "Part-03",
|
||||
SerialNumber = "SN-DATA"
|
||||
};
|
||||
|
||||
await store.BeginRunAsync(run);
|
||||
await store.CompleteRunAsync(run.RunId);
|
||||
|
||||
var manifestPath = Path.Combine(
|
||||
dataRoot,
|
||||
"InspectionResults",
|
||||
run.ResultRootPath.Replace('/', Path.DirectorySeparatorChar),
|
||||
"manifest.json");
|
||||
|
||||
Assert.True(File.Exists(manifestPath));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_dbContext.Dispose();
|
||||
|
||||
@@ -16,6 +16,7 @@ using XP.Common.Logging.Interfaces;
|
||||
using XplorePlane.Models;
|
||||
using XplorePlane.Services.AppState;
|
||||
using XplorePlane.Services.Cnc;
|
||||
using XplorePlane.Services.Storage;
|
||||
using XplorePlane.ViewModels.Cnc;
|
||||
using Xunit;
|
||||
|
||||
@@ -32,7 +33,9 @@ namespace XplorePlane.Tests.ViewModels
|
||||
var mockCncProgramSvc = new Mock<ICncProgramService>();
|
||||
var mockAppState = new Mock<IAppStateService>();
|
||||
var mockLogger = new Mock<ILoggerService>();
|
||||
var mockDataPathService = new Mock<IXpDataPathService>();
|
||||
mockLogger.Setup(l => l.ForModule<CncEditorViewModel>()).Returns(mockLogger.Object);
|
||||
mockDataPathService.SetupGet(s => s.PlanPath).Returns(System.IO.Path.GetTempPath());
|
||||
|
||||
mockExecSvc ??= new Mock<ICncExecutionService>();
|
||||
|
||||
@@ -52,7 +55,8 @@ namespace XplorePlane.Tests.ViewModels
|
||||
mockAppState.Object,
|
||||
new EventAggregator(),
|
||||
mockLogger.Object,
|
||||
mockExecSvc.Object);
|
||||
mockExecSvc.Object,
|
||||
mockDataPathService.Object);
|
||||
|
||||
if (initialProgram != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user