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

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

            for (int n = 1; n < b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 20, 5, PlayerSlot.Defender);
            }

            b.UpdateGame(1, 1, 0, 10, PlayerSlot.Challenger);
            Assert.IsFalse(b.GetMatch(b.GetMatch(1).NextLoserMatchNumber).IsFinished);
        }
        public void DEB_CreateBracket_DoesNotAdvanceLosersFromPlayinRound()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 0; i < 15; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new DoubleElimBracket(pList);

            //b.CreateBracket(2);

            Assert.AreEqual(-1, b.GetMatch(1).NextLoserMatchNumber);
        }
        public void DEBResetMatch_Resets()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

            b.AddGame(1, 1, 0, PlayerSlot.Defender);
            b.AddGame(1, 0, 1, PlayerSlot.Challenger);

            b.ResetMatchScore(1);
            Assert.AreEqual(0, b.GetMatch(1).Score[(int)PlayerSlot.Defender]);
        }
        public void DEB_AddGame_MovesLoserToLowerBracket()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

            //b.CreateBracket();

            b.AddGame(2, 0, 10, PlayerSlot.Challenger);
            Assert.AreEqual(b.GetMatch(2).Players[(int)PlayerSlot.Defender],
                            b.GetLowerRound(1)[0].Players[(int)PlayerSlot.Challenger]);
        }
        public void DEBAddGame_MovesLowerWinnerToGrandFinal()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 0; i < 4; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new DoubleElimBracket(pList);

            //b.CreateBracket();

            for (int n = 1; n < b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.AreEqual(b.GetMatch(5).Players[(int)PlayerSlot.Defender],
                            b.GrandFinal.Players[(int)PlayerSlot.Challenger]);
        }
        public void DEBAddGame_DropsLoserFromSecondRound()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 0; i < 4; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new DoubleElimBracket(pList);

            //b.CreateBracket();

            b.AddGame(1, 1, 0, PlayerSlot.Defender);
            b.AddGame(2, 1, 0, PlayerSlot.Defender);

            b.AddGame(3, 1, 0, PlayerSlot.Defender);
            Assert.AreEqual(b.GetMatch(3).Players[(int)PlayerSlot.Challenger],
                            b.GetLowerRound(2)[0].Players[(int)PlayerSlot.Defender]);
        }
        public void DEBAddGame_LowerBracketWins_AddsLoserToRankingsList()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 0; i < 4; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new DoubleElimBracket(pList);

            //b.CreateBracket();

            for (int n = 1; n <= 4; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }
            Assert.AreEqual(b.GetMatch(4).Players[(int)PlayerSlot.Challenger].Id,
                            b.Rankings[0].Id);
        }
        public void DEBResetMatch_ResetsALargeBracket()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

            for (int n = 1; n < b.NumberOfMatches; ++n)
            {
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
                b.AddGame(n, 0, 1, PlayerSlot.Challenger);
                b.AddGame(n, 1, 0, PlayerSlot.Defender);
            }

            b.ResetMatchScore(2);
            Assert.AreEqual(0, b.GetMatch(2).Score[(int)PlayerSlot.Challenger]);
        }
        public void DEBRemoveLastGame_RemovesFromLowerBracket()
        {
            List <IPlayer> pList = new List <IPlayer>();

            for (int i = 0; i < 4; ++i)
            {
                Mock <IPlayer> moq = new Mock <IPlayer>();
                moq.Setup(p => p.Id).Returns(i);
                pList.Add(moq.Object);
            }
            IBracket b = new DoubleElimBracket(pList);

            b.AddGame(1, 1, 0, PlayerSlot.Defender);
            b.AddGame(2, 1, 0, PlayerSlot.Defender);
            b.SetMaxGamesForWholeLowerRound(1, 3);
            int mNum = b.GetLowerRound(1)[0].MatchNumber;

            b.AddGame(mNum, 1, 0, PlayerSlot.Defender);

            b.RemoveLastGame(mNum);
            Assert.AreEqual(0, b.GetMatch(mNum).Score[(int)PlayerSlot.Defender]);
        }