src/GenFx.Tests/GeneticAlgorithmTest.cs
/// <summary>
/// Tests that metrics are sorted according to dependencies.
/// </summary>
Tests that metrics are sorted according to dependencies.
Tests that metrics are sorted according to dependencies .
[Fact]
        public async Task GeneticAlgorithm_InitializeAsync_SortMetrics()
        {
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                SelectionOperator = new MockSelectionOperator(),
                FitnessEvaluator = new MockFitnessEvaluator(),
                PopulationSeed = new MockPopulation(),
                GeneticEntitySeed = new MockEntity()
            };
            Metric1 metric1;
            Metric2 metric2;
            Metric3 metric3;
            Metric4 metric4;
            Metric5 metric5;
            algorithm.Metrics.AddRange(new Metric[]
            {
                metric1 = new Metric1(),
                metric2 = new Metric2(),
                metric3 = new Metric3(),
                metric4 = new Metric4(),
                metric5 = new Metric5(),
            });
            await algorithm.InitializeAsync();
            PrivateObject accessor = new PrivateObject(algorithm, new PrivateType(typeof(GeneticAlgorithm)));
            List<Metric> metrics = (List<Metric>)accessor.GetField("sortedMetrics");
            Assert.Equal(new Metric[]
            {
                metric5,
                metric3,
                metric2,
                metric4,
                metric1
            }, metrics);
        }
[ Fact ] public async Task GeneticAlgorithm_InitializeAsync_SortMetrics ( ) { MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { SelectionOperator = new MockSelectionOperator ( ) , FitnessEvaluator = new MockFitnessEvaluator ( ) , PopulationSeed = new MockPopulation ( ) , GeneticEntitySeed = new MockEntity ( ) } ; Metric1 metric1 ; Metric2 metric2 ; Metric3 metric3 ; Metric4 metric4 ; Metric5 metric5 ; algorithm . Metrics . AddRange ( new Metric [ ] { metric1 = new Metric1 ( ) , metric2 = new Metric2 ( ) , metric3 = new Metric3 ( ) , metric4 = new Metric4 ( ) , metric5 = new Metric5 ( ) , } ) ; await algorithm . InitializeAsync ( ) ; PrivateObject accessor = new PrivateObject ( algorithm , new PrivateType ( typeof ( GeneticAlgorithm ) ) ) ; List < Metric > metrics = ( List < Metric > ) accessor . GetField ( " " ) ; Assert . Equal ( new Metric [ ] { metric5 , metric3 , metric2 , metric4 , metric1 } , metrics ) ; }
Tests that metrics are sorted according to dependencies.
Tests that metrics are sorted according to dependencies .