src/GenFx.Tests/GeneticEnvironmentTest.cs
/// <summary>
/// Tests that EvaluateFitness works correctly.
/// </summary>
Tests that EvaluateFitness works correctly.
Tests that EvaluateFitness works correctly .
[Fact]
        public async Task GeneticEnvironment_EvaluateFitness_Async()
        {
            GeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                PopulationSeed = new MockPopulation(),
                GeneticEntitySeed = new MockEntity(),
                FitnessEvaluator = new MockFitnessEvaluator(),
                SelectionOperator = new MockSelectionOperator
                {
                    SelectionBasedOnFitnessType = FitnessType.Scaled
                }
            };
            algorithm.FitnessEvaluator = new MockFitnessEvaluator();
            algorithm.FitnessEvaluator.Initialize(algorithm);
            algorithm.SelectionOperator = new MockSelectionOperator();
            algorithm.SelectionOperator.Initialize(algorithm);
            GeneticEnvironment environment = new GeneticEnvironment(algorithm);
            MockPopulation population1 = GetPopulation(algorithm);
            MockPopulation population2 = GetPopulation(algorithm);
            environment.Populations.Add(population1);
            environment.Populations.Add(population2);
            await environment.EvaluateFitnessAsync();
            VerifyFitnessEvaluation(population1);
            VerifyFitnessEvaluation(population2);
        }
[ Fact ] public async Task GeneticEnvironment_EvaluateFitness_Async ( ) { GeneticAlgorithm algorithm = new MockGeneticAlgorithm { PopulationSeed = new MockPopulation ( ) , GeneticEntitySeed = new MockEntity ( ) , FitnessEvaluator = new MockFitnessEvaluator ( ) , SelectionOperator = new MockSelectionOperator { SelectionBasedOnFitnessType = FitnessType . Scaled } } ; algorithm . FitnessEvaluator = new MockFitnessEvaluator ( ) ; algorithm . FitnessEvaluator . Initialize ( algorithm ) ; algorithm . SelectionOperator = new MockSelectionOperator ( ) ; algorithm . SelectionOperator . Initialize ( algorithm ) ; GeneticEnvironment environment = new GeneticEnvironment ( algorithm ) ; MockPopulation population1 = GetPopulation ( algorithm ) ; MockPopulation population2 = GetPopulation ( algorithm ) ; environment . Populations . Add ( population1 ) ; environment . Populations . Add ( population2 ) ; await environment . EvaluateFitnessAsync ( ) ; VerifyFitnessEvaluation ( population1 ) ; VerifyFitnessEvaluation ( population2 ) ; }
Tests that EvaluateFitness works correctly.
Tests that EvaluateFitness works correctly .