public void GSLCtor_ThrowsBracketExcep_WithNonStandardPlayerCount()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 6; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);
        }
        public void GSLCreateBracket_CreatesTenMatches_ForTwoGroupsOfFour()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            Assert.AreEqual(10, b.NumberOfMatches);
        }
        public void GSLCreateBracket_ThrowsBracketExcep_WithNegativeGamesPerMatch()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2, 0);

            Assert.AreEqual(1, 2);
        }
        public void GSLCtor_Constructs()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            Assert.IsInstanceOfType(b, typeof(GSLGroups));
        }
        public void GSLCreateBracket_EachGroupTakesFourPlayers()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            Assert.AreEqual(4, (b as IGroupStage).GetGroup(1).NumberOfPlayers());
        }
        public void GSLCreateBracket_GroupStageStoresAllEightPlayers()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            Assert.AreEqual(pList.Count, b.NumberOfPlayers());
        }
        public void GSLCreateBracket_CorrectlyAssignsNumberOfRounds()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            Assert.AreEqual(2, b.NumberOfRounds);
        }
        public void GSLAddGame_SetsGroupStageAsFinishedWhenAllMatchesAreDone()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            for (int n = 1; n <= b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.IsTrue(b.IsFinished);
        }
        public void GSLAddGame_CorrectlyAddsGamesToAllRemainingMatches()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            for (int n = 1; n <= b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.AreEqual(b.NumberOfPlayers(), b.Rankings.Count);
        }
        public void GSLAddGame_DoesNotTryToAdvancePlayersToGrandFinal()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            for (int n = 1; n <= 3; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.AreEqual(PlayerSlot.Defender, b.GetMatch(3).WinnerSlot);
        }
        public void GSLAddGame_HasOneFirstPlaceRankerForEachGroup()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 1; i <= 8; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new GSLGroups(pList, 2);

            for (int n = 1; n <= b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.AreEqual((b as IGroupStage).NumberOfGroups,
                            b.Rankings.Where(r => r.Rank == 1).ToList().Count);
        }
        public void GSLCtor_ThrowsNull_WithNullParameter()
        {
            IBracket b = new GSLGroups(null, 2);

            Assert.AreEqual(1, 2);
        }
        public void GSLCtor_ThrowsOutOfRange_WithTooFewGroups()
        {
            IBracket b = new GSLGroups(new List <IPlayer>(), 1);

            Assert.AreEqual(1, 2);
        }