46 lines
1.6 KiB
C#
46 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);
|
|
|
|
var advisor = AlgorithmFactory.Create<IDefenseAdvisor>();
|
|
Assert.IsType<DefaultDefenseAdvisor>(advisor);
|
|
}
|
|
|
|
[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 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) { }
|
|
}
|
|
}
|