src/GenFx.Tests/GeneticAlgorithmTest.cs
/// <summary>
/// Tests that the <see cref="GeneticAlgorithm.AlgorithmCompleted"/> event is raised correctly
/// when the algorithm naturally finishes its execution via the terminator.
/// </summary>
Tests that the  event is raised correctly
when the algorithm naturally finishes its execution via the terminator.
Tests that the event is raised correctly when the algorithm naturally finishes its execution via the terminator .
[Fact]
        public async Task GeneticAlgorithm_AlgorithmCompletedEvent_ViaNaturalCompletion()
        {
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                GeneticEntitySeed = new MockEntity(),
                SelectionOperator = new MockSelectionOperator(),
                PopulationSeed = new MockPopulation(),
                FitnessEvaluator = new MockFitnessEvaluator(),
                Terminator = new MockTerminator()
            };
            AlgorithmCompletedPlugin plugin = new AlgorithmCompletedPlugin();
            algorithm.Plugins.Add(plugin);
            await algorithm.InitializeAsync();
            await algorithm.RunAsync();
            bool eventRaised = false;
            algorithm.AlgorithmCompleted += (sender, eventObj) =>
            {
                eventRaised = true;
            };
            algorithm.Complete();
            Assert.True(eventRaised);
            Assert.True(plugin.OnAlgorithmCompletedWasCalled);
        }
[ Fact ] public async Task GeneticAlgorithm_AlgorithmCompletedEvent_ViaNaturalCompletion ( ) { MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { GeneticEntitySeed = new MockEntity ( ) , SelectionOperator = new MockSelectionOperator ( ) , PopulationSeed = new MockPopulation ( ) , FitnessEvaluator = new MockFitnessEvaluator ( ) , Terminator = new MockTerminator ( ) } ; AlgorithmCompletedPlugin plugin = new AlgorithmCompletedPlugin ( ) ; algorithm . Plugins . Add ( plugin ) ; await algorithm . InitializeAsync ( ) ; await algorithm . RunAsync ( ) ; bool eventRaised = false ; algorithm . AlgorithmCompleted += ( sender , eventObj ) => { eventRaised = true ; } ; algorithm . Complete ( ) ; Assert . True ( eventRaised ) ; Assert . True ( plugin . OnAlgorithmCompletedWasCalled ) ; }
Tests that the  event is raised correctly
when the algorithm naturally finishes its execution via the terminator.
Tests that the event is raised correctly when the algorithm naturally finishes its execution via the terminator .