コード例 #1
0
        public void Select_NumberToSelectGreaterThanPopulationSize_Throws()
        {
            var selector = new ParentSelectionRoulette(false);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                        selector.Select(testPop, testPop.Count() + 1));
        }
コード例 #2
0
        public void Select_RequestFive_BestAlwaysReturned_GetFiveIncludingBest()
        {
            var selector = new ParentSelectionRoulette(true);
            var parents  = selector.Select(testPop, 5);

            Assert.True(parents.Count() == 5);
            Assert.Contains(testPop.Best(), parents);
        }
コード例 #3
0
        public void Select_RequestOne_BestAlwaysReturned_GetBest()
        {
            var selector = new ParentSelectionRoulette(true);
            var parents  = selector.Select(testPop, 1);

            Assert.True(parents.Count() == 1);
            Assert.Equal(testPop.Best(), parents.ElementAt(0));
        }