src/GenFx.Components.Tests/FitnessTargetTerminatorTest.cs
/// <summary>
/// Tests that the <see cref="FitnessTargetTerminator.IsComplete"/> method works correctly.
/// </summary>
Tests that the  method works correctly.
Tests that the method works correctly .
[Fact]
        public async Task FitnessTargetTerminator_IsComplete_RawFitness()
        {
            double fitnessTarget = 15;
            GeneticAlgorithm algorithm = GetAlgorithm(fitnessTarget, FitnessType.Raw);
            await algorithm.InitializeAsync();
            FitnessTargetTerminator terminator = (FitnessTargetTerminator)algorithm.Terminator;
            terminator.Initialize(algorithm);
            Assert.False(terminator.IsComplete(), "No genetic entities have the fitness target.");
            MockEntity entity = new MockEntity();
            entity.Initialize(algorithm);
            SimplePopulation population = new SimplePopulation();
            population.Initialize(algorithm);
            population.Entities.Add(entity);
            algorithm.Environment.Populations.Add(population);
            Assert.False(terminator.IsComplete(), "No genetic entities have the fitness target.");
            PrivateObject accessor = new PrivateObject(entity, new PrivateType(typeof(GeneticEntity)));
            accessor.SetField("rawFitnessValue", 15);
            Assert.True(terminator.IsComplete(), "A entity does have the fitness target.");
        }
[ Fact ] public async Task FitnessTargetTerminator_IsComplete_RawFitness ( ) { double fitnessTarget = 15 ; GeneticAlgorithm algorithm = GetAlgorithm ( fitnessTarget , FitnessType . Raw ) ; await algorithm . InitializeAsync ( ) ; FitnessTargetTerminator terminator = ( FitnessTargetTerminator ) algorithm . Terminator ; terminator . Initialize ( algorithm ) ; Assert . False ( terminator . IsComplete ( ) , " " ) ; MockEntity entity = new MockEntity ( ) ; entity . Initialize ( algorithm ) ; SimplePopulation population = new SimplePopulation ( ) ; population . Initialize ( algorithm ) ; population . Entities . Add ( entity ) ; algorithm . Environment . Populations . Add ( population ) ; Assert . False ( terminator . IsComplete ( ) , " " ) ; PrivateObject accessor = new PrivateObject ( entity , new PrivateType ( typeof ( GeneticEntity ) ) ) ; accessor . SetField ( " " , 15 ) ; Assert . True ( terminator . IsComplete ( ) , " " ) ; }
Tests that the  method works correctly.
Tests that the method works correctly .
// Check with no populations // Check with a population with one entity