CounterDroneBackend/test/unit/CounterDrone.Core.Tests/ReportGeneratorTests.cs
tian ca0ce8aa52 重命名核心模型:TargetConfig→DroneProfile, SimTask→Scenario, TaskFullConfig→ScenarioConfig, TaskId→ScenarioId
- DroneType 枚举清理:移除 Electric/Piston,重编号 HighSpeed=2
- planner_config.json / defaults.json 同步迁移
- 238 单元测试全部通过
2026-06-18 15:02:58 +08:00

63 lines
2.4 KiB
C#

using System.Collections.Generic;
using CounterDrone.Core.Models;
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
{
Task = new Scenario { Name = "测试任务", TaskNumber = "SIM-001" },
Targets = new List<DroneProfile> { new DroneProfile { Quantity = 1 } },
Equipment = new List<EquipmentDeployment>
{
new EquipmentDeployment { EquipmentRole = (int)EquipmentRole.LaunchPlatform, Quantity = 3 },
new EquipmentDeployment { EquipmentRole = (int)EquipmentRole.Detection, Quantity = 1 },
},
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 content = gen.Generate(config, events, DroneStatus.Destroyed, 30f);
Assert.Contains("仿真评估报告", content);
Assert.Contains("测试任务", content);
Assert.Contains("✅ 成功拦截", content);
Assert.Contains("发射", content);
}
}
}