src/GenFx.Tests/GeneticAlgorithmTest.cs
/// <summary>
/// Tests that external configuration properties are validated when the algorithm is initialized.
/// </summary>
Tests that external configuration properties are validated when the algorithm is initialized.
Tests that external configuration properties are validated when the algorithm is initialized .
[Fact]
        public async Task GeneticAlgorithm_ExternalConfigurationPropertyValidation()
        {
            CustomGeneticAlgorithm algorithm = new CustomGeneticAlgorithm
            {
                CrossoverOperator = new CustomCrossoverOperator(),
                ElitismStrategy = new CustomElitismStrategy(),
                FitnessEvaluator = new CustomFitnessEvaluator(),
                FitnessScalingStrategy = new CustomFitnessScalingStrategy(),
                GeneticEntitySeed = new CustomGeneticEntity(),
                MutationOperator = new CustomMutationOperator(),
                PopulationSeed = new CustomPopulation(),
                SelectionOperator = new CustomSelectionOperator(),
                Terminator = new CustomTerminator()
            };
            algorithm.Plugins.Add(new CustomPlugin());
            algorithm.Metrics.Add(new CustomMetric());
            await algorithm.InitializeAsync();
            foreach (ICustomComponent component in algorithm.GetAllComponents())
            {
                await TestExternalConfigurationPropertyValidation(algorithm, component);
            }
            await TestExternalConfigurationPropertyValidation(algorithm, algorithm);
        }
[ Fact ] public async Task GeneticAlgorithm_ExternalConfigurationPropertyValidation ( ) { CustomGeneticAlgorithm algorithm = new CustomGeneticAlgorithm { CrossoverOperator = new CustomCrossoverOperator ( ) , ElitismStrategy = new CustomElitismStrategy ( ) , FitnessEvaluator = new CustomFitnessEvaluator ( ) , FitnessScalingStrategy = new CustomFitnessScalingStrategy ( ) , GeneticEntitySeed = new CustomGeneticEntity ( ) , MutationOperator = new CustomMutationOperator ( ) , PopulationSeed = new CustomPopulation ( ) , SelectionOperator = new CustomSelectionOperator ( ) , Terminator = new CustomTerminator ( ) } ; algorithm . Plugins . Add ( new CustomPlugin ( ) ) ; algorithm . Metrics . Add ( new CustomMetric ( ) ) ; await algorithm . InitializeAsync ( ) ; foreach ( ICustomComponent component in algorithm . GetAllComponents ( ) ) { await TestExternalConfigurationPropertyValidation ( algorithm , component ) ; } await TestExternalConfigurationPropertyValidation ( algorithm , algorithm ) ; }
Tests that external configuration properties are validated when the algorithm is initialized.
Tests that external configuration properties are validated when the algorithm is initialized .
// Ensure the algorithm can be initialized without error