- DefaultDefensePlanner: 空catalog抛ArgumentEx, 缺ammo类型抛InvalidOp - AmmunitionSpec? → AmmunitionSpec(非空), 删除 ==null 静默返回 - 删除 0.8f射程安全系数, 1.5f时间窗口乘数 - AlgorithmFactory 移除IDefensePlanner(null)注册 - SimulationEngine 构造必须传planner,6个调用点全部更新
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using CounterDrone.Core.Algorithms;
|
|
using Xunit;
|
|
|
|
namespace CounterDrone.Core.Tests
|
|
{
|
|
public class AlgorithmFactoryTests
|
|
{
|
|
[Fact]
|
|
public void Create_ReturnsDefaultImplementations()
|
|
{
|
|
var dispersion = AlgorithmFactory.Create<ICloudDispersionModel>();
|
|
Assert.IsType<GaussianPuffDispersion>(dispersion);
|
|
|
|
var damage = AlgorithmFactory.Create<IDamageModel>();
|
|
Assert.IsType<DamageModelRouter>(damage);
|
|
}
|
|
|
|
[Fact]
|
|
public void Register_ReplacesImplementation()
|
|
{
|
|
AlgorithmFactory.Register<ICloudDispersionModel>(() => new MockDispersion());
|
|
var instance = AlgorithmFactory.Create<ICloudDispersionModel>();
|
|
Assert.IsType<MockDispersion>(instance);
|
|
AlgorithmFactory.Register<ICloudDispersionModel>(() => new GaussianPuffDispersion());
|
|
}
|
|
}
|
|
|
|
public class MockDispersion : ICloudDispersionModel
|
|
{
|
|
public Vector3 Center => new();
|
|
public float Radius => 100f;
|
|
public float CoreDensity => 1f;
|
|
public float EffectiveRadius => 100f;
|
|
public ParticleParams Particles => new();
|
|
public bool IsDissipated => false;
|
|
public int Phase => 2;
|
|
public float Elapsed => 10f;
|
|
|
|
public void Initialize(CounterDrone.Core.Models.AmmunitionSpec ammo,
|
|
CounterDrone.Core.Models.CombatScene env, Vector3 releasePos, float releaseTime)
|
|
{ }
|
|
public void Tick(float deltaTime, float windSpeed,
|
|
CounterDrone.Core.Models.WindDirection windDir)
|
|
{ }
|
|
}
|
|
}
|