src/GenFx.Tests/GeneticEntityCollectionExtensionsTest.cs
/// <summary>
/// Tests that <see cref="GeneticEntityCollectionExtensions.GetEntitiesSortedByFitness"/> method works correctly.
/// </summary>
Tests that  method works correctly.
Tests that method works correctly .
[Fact]
        public async Task GeneticEntityCollectionExtensions_GetEntitiesSortedByFitness_SortRawMaximize()
        {
            TestEntity testEntity1 = new TestEntity { TestFitnessValue = 1 };
            TestEntity testEntity2 = new TestEntity { TestFitnessValue = 3 };
            TestEntity testEntity3 = new TestEntity { TestFitnessValue = 2 };
            List<GeneticEntity> entities = new List<GeneticEntity>
            {
                testEntity1,
                testEntity2,
                testEntity3,
            };
            MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm
            {
                FitnessEvaluator = new TestFitnessEvalutor()
            };
            foreach (GeneticEntity entity in entities)
            {
                entity.Initialize(algorithm);
                await entity.EvaluateFitnessAsync();
            }
            List<GeneticEntity> results = GeneticEntityCollectionExtensions.GetEntitiesSortedByFitness(entities, FitnessType.Raw, FitnessEvaluationMode.Maximize).ToList();
            Assert.Equal(3, results.Count);
            Assert.Same(testEntity1, results[0]);
            Assert.Same(testEntity3, results[1]);
            Assert.Same(testEntity2, results[2]);
        }
[ Fact ] public async Task GeneticEntityCollectionExtensions_GetEntitiesSortedByFitness_SortRawMaximize ( ) { TestEntity testEntity1 = new TestEntity { TestFitnessValue = 1 } ; TestEntity testEntity2 = new TestEntity { TestFitnessValue = 3 } ; TestEntity testEntity3 = new TestEntity { TestFitnessValue = 2 } ; List < GeneticEntity > entities = new List < GeneticEntity > { testEntity1 , testEntity2 , testEntity3 , } ; MockGeneticAlgorithm algorithm = new MockGeneticAlgorithm { FitnessEvaluator = new TestFitnessEvalutor ( ) } ; foreach ( GeneticEntity entity in entities ) { entity . Initialize ( algorithm ) ; await entity . EvaluateFitnessAsync ( ) ; } List < GeneticEntity > results = GeneticEntityCollectionExtensions . GetEntitiesSortedByFitness ( entities , FitnessType . Raw , FitnessEvaluationMode . Maximize ) . ToList ( ) ; Assert . Equal ( 3 , results . Count ) ; Assert . Same ( testEntity1 , results [ 0 ] ) ; Assert . Same ( testEntity3 , results [ 1 ] ) ; Assert . Same ( testEntity2 , results [ 2 ] ) ; }
Tests that  method works correctly.
Tests that method works correctly .