Exemplo n.º 1
0
        public void TheTenLargestIntegersInALargeConsecutiveSequenceAre()
        {
            var set = new FitnessSet<int>( maxSize: 10, compareFitness: CompareIntegers );
            const int Max = 10000000;
            for( int i = 0; i < Max; i++ )
                set.ObserveEntity( i );

            int[] expectedSet = Enumerable.Range( Max - 10, 10 ).ToArray();
            CollectionAssert.AreEqual( expectedSet, set.MostFitEntities );
        }
Exemplo n.º 2
0
        public void TheTenLargestIntegersInALargeRandomSequenceAre()
        {
            var set = new FitnessSet<int>( maxSize: 10, compareFitness: CompareIntegers );

            // NOTE: We use a fixed seed so that the pseudo-random numbers generated
            // across test runs are consistent, making the output consistent.
            Random rnd = new Random( Seed: 0 );
            const int Max = 10000000;
            for( int i = 0; i < Max; i++ )
            {
                int value = rnd.Next( Max );
                set.ObserveEntity( value );
            }

            int[] expectedSet = { 9999961, 9999984, 9999985, 9999987, 9999988, 9999989, 9999993, 9999995, 9999997, 9999999 };
            CollectionAssert.AreEqual( expectedSet, set.MostFitEntities );
        }