Ejemplo n.º 1
0
        private void SetDefaults()
        {
            turnamentor = new Turnamentor <ScoreBoard, Score>();
            turnamentor.SetContstantType <Contestant>();
            if (typeof(ScoreBoard).GetConstructor(Type.EmptyTypes) != null)
            {
                turnamentor.ScoreBoardInstance = (ScoreBoard)Activator.CreateInstance(typeof(ScoreBoard));
            }

            roundSelectorConfig = new RoundSelectorConfig
            {
                NumberOfContestantsInRound = 2,
                Contestants = new List <Type>()
            };
            roundSelectorProvider = config => new AllWithAllSelector <Contestant>(config);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            // arrange
            var confing = new RoundSelectorConfig
            {
                Contestants = new List <Type>()
                {
                    typeof(A), typeof(B), typeof(C), typeof(D)
                },
                NumberOfContestantsInRound = 2
            };
            var selector = new AllWithAllSelector <I>(confing);

            // act
            var allRounds = selector.GetAllRounds()
                            .Select(x => x.Cast <I>()).ToList();

            // assert
            var allRoundsStrings = allRounds
                                   .Select(contestants =>
            {
                var sb     = new StringBuilder();
                var sorted = contestants.OrderBy(x => x.Id);

                foreach (var contestant in contestants)
                {
                    sb.Append(contestant.Id);
                }

                return(sb.ToString());
            })
                                   .OrderBy(x => x)
                                   .ToList();

            var expected = new List <string>
            {
                "AB", "AC", "AD", "BC", "BD", "CD"
            };

            CollectionAssert.AreEqual(expected, allRoundsStrings);
        }