public void SetUp() { this.particleGenerator = new Mock <IParticleGenerator>(); this.particleGenerator.Setup(foo => foo.Generate(It.IsAny <int>(), It.IsAny <float>(), It.IsAny <float>())).Returns <int, float, float>((par, min, max) => Enumerable.Repeat(min, par).ToArray()); this.particleAmount = 5; this.minValue = 0; this.maxValue = 1; this.controller = new LinearParticleController(this.particleGenerator.Object, this.particleAmount, this.minValue, this.maxValue); }
public void TestWeightedAverage2() { float[] values = { 359, 1 }; float[] weights = { 0.5f, 0.5f }; this.particleGenerator.Setup(foo => foo.Generate(It.IsAny <int>(), 0, 359)).Returns(values); LinearParticleController cont = new LinearParticleController(this.particleGenerator.Object, 2, 0, 359); cont.Weights = weights; Assert.AreEqual(180, cont.WeightedAverage()); }
public void TestWeightedAverage() { float[] values = { -1f, 0, 1, 1 }; float[] weights = { 0.5f, 0f, 0.25f, 0.25f }; this.particleGenerator.Setup(foo => foo.Generate(It.IsAny <int>(), -1, 1)).Returns(values); LinearParticleController cont = new LinearParticleController(this.particleGenerator.Object, 4, -1, 1); cont.Weights = weights; Assert.AreEqual(0, this.controller.WeightedAverage()); }