src/GenFx.Tests/GeneticEnvironmentTest.cs
/// <summary>
/// Tests that Generate works correctly.
/// </summary>
Tests that Generate works correctly.
Tests that Generate works correctly .
[Fact]
        public async Task GeneticEnvironment_Initialize_Async()
        {
            int environmentSize = 2;
            int populationSize = 5;
            GeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                FitnessEvaluator = new MockFitnessEvaluator(),
                SelectionOperator = new MockSelectionOperator(),
                GeneticEntitySeed = new MockEntity(),
                MinimumEnvironmentSize = environmentSize,
                PopulationSeed = new MockPopulation
                {
                    MinimumPopulationSize = populationSize
                }
            };
            algorithm.GeneticEntitySeed.Initialize(algorithm);
            algorithm.PopulationSeed.Initialize(algorithm);
            GeneticEnvironment environment = new GeneticEnvironment(algorithm);
            await environment.InitializeAsync();
            Assert.Equal(environmentSize, environment.Populations.Count);
            for (int i = 0; i < environmentSize; i++)
            {
                Assert.Equal(i, environment.Populations[i].Index);
                Assert.IsType<MockPopulation>(environment.Populations[i]);
                Assert.Equal(populationSize, environment.Populations[i].Entities.Count);
            }
        }
[ Fact ] public async Task GeneticEnvironment_Initialize_Async ( ) { int environmentSize = 2 ; int populationSize = 5 ; GeneticAlgorithm algorithm = new MockGeneticAlgorithm { FitnessEvaluator = new MockFitnessEvaluator ( ) , SelectionOperator = new MockSelectionOperator ( ) , GeneticEntitySeed = new MockEntity ( ) , MinimumEnvironmentSize = environmentSize , PopulationSeed = new MockPopulation { MinimumPopulationSize = populationSize } } ; algorithm . GeneticEntitySeed . Initialize ( algorithm ) ; algorithm . PopulationSeed . Initialize ( algorithm ) ; GeneticEnvironment environment = new GeneticEnvironment ( algorithm ) ; await environment . InitializeAsync ( ) ; Assert . Equal ( environmentSize , environment . Populations . Count ) ; for ( int i = 0 ; i < environmentSize ; i ++ ) { Assert . Equal ( i , environment . Populations [ i ] . Index ) ; Assert . IsType < MockPopulation > ( environment . Populations [ i ] ) ; Assert . Equal ( populationSize , environment . Populations [ i ] . Entities . Count ) ; } }
Tests that Generate works correctly.
Tests that Generate works correctly .