src/GenFx.Components.Tests/ExponentialScalingStrategyTest.cs
/// <summary>
/// Tests that the Scale method works correctly.
/// </summary>
Tests that the Scale method works correctly.
Tests that the Scale method works correctly .
[Fact]
        public void ExponentialScalingStrategy_Scale()
        {
            GeneticAlgorithm algorithm = GetAlgorithm(2);
            ExponentialScalingStrategy target = (ExponentialScalingStrategy)algorithm.FitnessScalingStrategy;
            target.Initialize(algorithm);
            SimplePopulation population = new SimplePopulation();
            population.Initialize(algorithm);
            MockEntity entity1 = new MockEntity();
            entity1.Initialize(algorithm);
            PrivateObject entity1Accessor = new PrivateObject(entity1, new PrivateType(typeof(GeneticEntity)));
            entity1Accessor.SetField("rawFitnessValue", 5);
            MockEntity entity2 = new MockEntity();
            entity2.Initialize(algorithm);
            PrivateObject entity2Accessor = new PrivateObject(entity2, new PrivateType(typeof(GeneticEntity)));
            entity2Accessor.SetField("rawFitnessValue", 7);
            population.Entities.Add(entity1);
            population.Entities.Add(entity2);
            target.Scale(population);
            Assert.Equal((double)25, entity1.ScaledFitnessValue);
            Assert.Equal((double)49, entity2.ScaledFitnessValue);
        }
[ Fact ] public void ExponentialScalingStrategy_Scale ( ) { GeneticAlgorithm algorithm = GetAlgorithm ( 2 ) ; ExponentialScalingStrategy target = ( ExponentialScalingStrategy ) algorithm . FitnessScalingStrategy ; target . Initialize ( algorithm ) ; SimplePopulation population = new SimplePopulation ( ) ; population . Initialize ( algorithm ) ; MockEntity entity1 = new MockEntity ( ) ; entity1 . Initialize ( algorithm ) ; PrivateObject entity1Accessor = new PrivateObject ( entity1 , new PrivateType ( typeof ( GeneticEntity ) ) ) ; entity1Accessor . SetField ( " " , 5 ) ; MockEntity entity2 = new MockEntity ( ) ; entity2 . Initialize ( algorithm ) ; PrivateObject entity2Accessor = new PrivateObject ( entity2 , new PrivateType ( typeof ( GeneticEntity ) ) ) ; entity2Accessor . SetField ( " " , 7 ) ; population . Entities . Add ( entity1 ) ; population . Entities . Add ( entity2 ) ; target . Scale ( population ) ; Assert . Equal ( ( double ) 25 , entity1 . ScaledFitnessValue ) ; Assert . Equal ( ( double ) 49 , entity2 . ScaledFitnessValue ) ; }
Tests that the Scale method works correctly.
Tests that the Scale method works correctly .