CounterDroneBackend/test/unit/CounterDrone.Core.Tests/ReportGeneratorTests.cs
tian 8bcf4cf675 VERSION 0.12.0 — PDF 导出 + 报告模板架构 + 对接文档 V2.0
- PdfSharpCore 1.3.64 引入(纯托管,Unity IL2CPP 兼容,+9 DLL)
- ReportData 结构化模型 + MarkdownRenderer + StandardPdfTemplate
- IReportService.ExportReport(id, format) 按需导出 PDF/MD
- 仿真后自动生成 MD 到 reports 目录,PDF 按需调用
- CJK 字体嵌入(SimHei),IPathProvider + GetFontPath
- ReportGenerator 重构为构建 ReportData,去掉 emoji
- check_unity_build.ps1 修复 -quit 参数缺失导致超时
- 对接文档 V2.0:坐标系/3D 可视化/完整枚举/Manager 签名/模型字段
- 262 测试全部通过
2026-06-20 11:57:38 +08:00

65 lines
2.5 KiB
C#

using System.Collections.Generic;
using CounterDrone.Core.Models;
using CounterDrone.Core.Reporting;
using CounterDrone.Core.Services;
using CounterDrone.Core.Simulation;
using Xunit;
namespace CounterDrone.Core.Tests
{
public class ReportGeneratorTests
{
[Fact]
public void DetermineInterceptResult_AllDestroyed_Success()
{
var gen = new ReportGenerator();
Assert.Equal(InterceptResult.Success, gen.DetermineInterceptResult(3, 0, 3));
}
[Fact]
public void DetermineInterceptResult_Partial()
{
var gen = new ReportGenerator();
Assert.Equal(InterceptResult.Partial, gen.DetermineInterceptResult(2, 1, 3));
}
[Fact]
public void DetermineInterceptResult_AllFailed()
{
var gen = new ReportGenerator();
Assert.Equal(InterceptResult.Failed, gen.DetermineInterceptResult(0, 3, 3));
}
[Fact]
public void Generate_ProducesReportContent()
{
var gen = new ReportGenerator();
var config = new ScenarioConfig
{
Info = new Scenario { Name = "测试任务", ScenarioNumber = "SIM-001" },
Drones = new List<ScenarioDrone> { TestData.CreateScenarioDrone("w1", 1) },
Units = new List<ScenarioUnit>
{
TestData.CreateScenarioUnit(0, 0, 50, 0, null),
TestData.CreateScenarioUnit(0, 0, 50, 0, null),
},
Cloud = new CloudDispersal { AerosolType = (int)AerosolType.InertGas },
};
var events = new List<SimEvent>
{
new SimEvent { Type = SimEventType.MunitionLaunched, OccurredAt = 5f, Description = "发射" },
new SimEvent { Type = SimEventType.CloudGenerated, OccurredAt = 10f, Description = "云团" },
new SimEvent { Type = SimEventType.DroneDestroyed, OccurredAt = 15f, Description = "摧毁" },
};
var data = gen.Generate(config, events, DroneStatus.Destroyed, 30f, TestData.EmptyDroneSpecs, TestData.EmptyFuSpecs, TestData.EmptySensorSpecs);
var content = new MarkdownRenderer().Render(data);
Assert.Contains("仿真评估报告", content);
Assert.Contains("测试任务", content);
Assert.Contains("成功拦截", content);
Assert.Contains("发射", content);
}
}
}