64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using CounterDrone.Core.Models;
|
|
using CounterDrone.Core.Services;
|
|
using CounterDrone.Core.Simulation;
|
|
using Xunit;
|
|
using SimEvent = CounterDrone.Core.Simulation.SimEvent;
|
|
|
|
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 TaskFullConfig
|
|
{
|
|
Task = new SimTask { Name = "测试任务", TaskNumber = "SIM-001" },
|
|
Targets = new List<TargetConfig> { new TargetConfig { 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);
|
|
}
|
|
}
|
|
}
|