コード例 #1
0
        public override bool ConstructGroupLayout(int playersPerGroupCount)
        {
            Matches = RoundRobinGroupLayoutAssembler.ConstructMathes(playersPerGroupCount, this);
            MarkAsModified();

            return(true);
        }
コード例 #2
0
        public void CanFillConstructedMatchesWithPlayers()
        {
            int          groupSizeCounter = 1;
            List <Match> matches;

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithTwoPlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithThreePlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithFourPlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithFivePlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithSixPlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithSevenPlayers(matches);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, groupSizeCounter), matches);
            RunTestsWithEightPlayers(matches);
        }
コード例 #3
0
        public void ConstructsAppropriateCountOfMatchesDependingOnGroupSize()
        {
            int          groupSizeCounter = 0;
            List <Match> matches;

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(0);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(1);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(3);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(6);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(10);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(15);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(21);

            matches = RoundRobinGroupLayoutAssembler.ConstructMathes(++groupSizeCounter, roundRobinGroup);
            matches.Should().HaveCount(28);
        }
コード例 #4
0
        public void CannotAssignPlayersToMatchesWhenMatchesCannotFitAllPlayerReferences()
        {
            int halfPlayerReferenceCount = playerReferences.Count / 2;

            List <Match> matches = RoundRobinGroupLayoutAssembler.ConstructMathes(halfPlayerReferenceCount, roundRobinGroup);

            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences, matches);

            foreach (Match match in matches)
            {
                match.Player1.PlayerReferenceId.Should().BeEmpty();
                match.Player2.PlayerReferenceId.Should().BeEmpty();
            }
        }
コード例 #5
0
        public void CanAssignPlayersToMatchesWhenPlayerReferencesWontFillAllMatches()
        {
            int halfPlayerReferenceCount = playerReferences.Count / 2;

            List <Match> matches = RoundRobinGroupLayoutAssembler.ConstructMathes(playerReferences.Count, roundRobinGroup);

            RoundRobinGroupLayoutAssembler.AssignPlayersToMatches(playerReferences.GetRange(0, halfPlayerReferenceCount), matches);

            int index             = 0;
            int validMatchesCount = 6;

            for (; index < validMatchesCount; ++index)
            {
                matches[index].Player1.PlayerReferenceId.Should().NotBeEmpty();
                matches[index].Player2.PlayerReferenceId.Should().NotBeEmpty();
            }

            for (; index < matches.Count; ++index)
            {
                matches[index].Player1.PlayerReferenceId.Should().BeEmpty();
                matches[index].Player2.PlayerReferenceId.Should().BeEmpty();
            }
        }
コード例 #6
0
 public void CannotConstructMatchesWithoutValidGroupProvided()
 {
     RoundRobinGroupLayoutAssembler.ConstructMathes(4, null).Should().BeEmpty();
 }