src/GenFx.Components.Tests/FitnessStandardDeviationTest.cs
/// <summary>
/// Tests that the <see cref="FitnessStandardDeviation.GetResultValue"/> method works correctly.
/// </summary>
Tests that the  method works correctly.
Tests that the method works correctly .
[Fact]
        public void FitnessStandardDeviation_GetResultValue_WithScaling()
        {
            FitnessStandardDeviation metric = new FitnessStandardDeviation();
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { FitnessScalingStrategy = new MockFitnessScalingStrategy() };
            MeanFitness meanFitness = new MeanFitness();
            meanFitness.GetResults(0).Add(new MetricResult(0, 0, (double)12, meanFitness));
            algorithm.Metrics.Add(meanFitness);
            metric.Initialize(algorithm);
            MockPopulation population = new MockPopulation();
            population.Entities.Add(new MockEntity { ScaledFitnessValue = 10 });
            population.Entities.Add(new MockEntity { ScaledFitnessValue = 11 });
            population.Entities.Add(new MockEntity { ScaledFitnessValue = 15 });
            object result = metric.GetResultValue(population);
            Assert.Equal(2.16025, Math.Round((double)result, 5));
        }
[ Fact ] public void FitnessStandardDeviation_GetResultValue_WithScaling ( ) { FitnessStandardDeviation metric = new FitnessStandardDeviation ( ) ; MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { FitnessScalingStrategy = new MockFitnessScalingStrategy ( ) } ; MeanFitness meanFitness = new MeanFitness ( ) ; meanFitness . GetResults ( 0 ) . Add ( new MetricResult ( 0 , 0 , ( double ) 12 , meanFitness ) ) ; algorithm . Metrics . Add ( meanFitness ) ; metric . Initialize ( algorithm ) ; MockPopulation population = new MockPopulation ( ) ; population . Entities . Add ( new MockEntity { ScaledFitnessValue = 10 } ) ; population . Entities . Add ( new MockEntity { ScaledFitnessValue = 11 } ) ; population . Entities . Add ( new MockEntity { ScaledFitnessValue = 15 } ) ; object result = metric . GetResultValue ( population ) ; Assert . Equal ( 2.16025 , Math . Round ( ( double ) result , 5 ) ) ; }
Tests that the  method works correctly.
Tests that the method works correctly .