- TestData 新增 CreateScenarioDrone/CreateScenarioUnit 等辅助方法 - 批量替换旧字段构造为 spec 引用 - 230/238 通过,8 个边缘测试待修
63 lines
2.4 KiB
C#
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<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 content = gen.Generate(config, events, DroneStatus.Destroyed, 30f, TestData.EmptyDroneSpecs, TestData.EmptyFuSpecs, TestData.EmptySensorSpecs);
|
|
|
|
Assert.Contains("仿真评估报告", content);
|
|
Assert.Contains("测试任务", content);
|
|
Assert.Contains("✅ 成功拦截", content);
|
|
Assert.Contains("发射", content);
|
|
}
|
|
}
|
|
}
|