CounterDroneBackend/test/unit/CounterDrone.Core.Tests/ReportGeneratorTests.cs
tian 67cea1490d Target→Profile / Targets→DroneProfiles 重命名
- DroneWave.Target → Profile
- ScenarioConfig.Targets → DroneProfiles
- DefensePlanner / SimulationEngine / ReportService 全部引用同步
- 更新 Unity DLL + defaults.json
- 238 测试全过
2026-06-18 15:37:25 +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
{
Info = new Scenario { Name = "测试任务", ScenarioNumber = "SIM-001" },
Drones = 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);
}
}
}