Files
WCTDataMiner/tests/Gpulse.WCT.DataAnalyzer.Tests/CliStructureTests.cs
Scottxjw 7a8a1e9a87 test: 更新分析功能和迁移测试用例
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-25 11:30:16 +08:00

56 lines
2.1 KiB
C#

using Gpulse.WCT.DataAnalyzer.Commands;
using Gpulse.WCT.DataAnalyzer.Core.Application;
using Gpulse.WCT.DataAnalyzer.Core.Application.Analysis;
using Gpulse.WCT.DataAnalyzer.Core.Application.Exporting;
using Microsoft.Extensions.DependencyInjection;
using System.CommandLine;
namespace Gpulse.WCT.DataAnalyzer.Tests;
[TestFixture]
public class CliStructureTests : CommandTestBase
{
/// <summary>按 Program.Main 的方式组装根命令。</summary>
private RootCommand BuildRoot()
{
var root = new RootCommand("Gpulse.WCT.DataAnalyzer - FOD Log Data Parser");
root.AddCommand(new ParseCommand(Host.Services.GetRequiredService<ParseService>()));
root.AddCommand(new AggregateCommand(Host.Services.GetRequiredService<AggregationService>()));
root.AddCommand(new ExportCommand(Host.Services.GetRequiredService<ExportService>()));
root.AddCommand(new CleanCommand(Host.Services.GetRequiredService<CleanService>()));
root.AddCommand(new AnalyzeCommand(
Host.Services.GetRequiredService<PlossAnalysisService>(),
Host.Services.GetRequiredService<QfodCalibrationService>(),
Host.Services.GetRequiredService<AnalyzeExcelExporter>()));
return root;
}
[Test]
public async Task Help_ListsAllSubcommands()
{
var (code, stdout, _) = await BuildRoot().RunCaptureAsync("--help");
Assert.Multiple(() =>
{
Assert.That(code, Is.EqualTo(0));
Assert.That(stdout, Does.Contain("parse"));
Assert.That(stdout, Does.Contain("aggregate"));
Assert.That(stdout, Does.Contain("export"));
Assert.That(stdout, Does.Contain("clean"));
Assert.That(stdout, Does.Contain("analyze"));
});
}
[Test]
public async Task UnknownCommand_ReturnsError()
{
var (code, stdout, stderr) = await BuildRoot().RunCaptureAsync("nosuchcommand");
Assert.Multiple(() =>
{
Assert.That(code, Is.EqualTo(1));
Assert.That(stdout + stderr, Does.Contain("nosuchcommand"));
});
}
}