public void RRBCreateBracket_AssignsCorrectMatchesPerPlayer()
        {
            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 RoundRobinBracket(pList);

            int numMatchesForPlayerOne = 0;

            for (int n = 1; n <= b.NumberOfMatches; ++n)
            {
                IMatch m = b.GetMatch(n);
                if (b.Players[0] == m.Players[(int)PlayerSlot.Defender] ||
                    b.Players[0] == m.Players[(int)PlayerSlot.Challenger])
                {
                    ++numMatchesForPlayerOne;
                }
            }

            Assert.AreEqual(3, numMatchesForPlayerOne);
        }
        public void RRB_ScoreAndRankingTracker()
        {
            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 RoundRobinBracket(pList);

            for (int n = 1; n <= b.NumberOfMatches; ++n)
            {
                IMatch m = b.GetMatch(n);
                if (m.Players[(int)PlayerSlot.Defender].Id > m.Players[(int)PlayerSlot.Challenger].Id)
                {
                    b.AddGame(n, 1, 0, PlayerSlot.Defender);
                }
                else
                {
                    b.AddGame(n, 0, 1, PlayerSlot.Challenger);
                }
            }

            Assert.AreEqual(1, 1);
        }
        public void RRBAddGame_UpdatesRankings()
        {
            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 RoundRobinBracket(pList);

            b.AddGame(1, 0, 1, PlayerSlot.Challenger);
            Assert.AreEqual(b.GetMatch(1).Players[(int)(b.GetMatch(1).WinnerSlot)].Id,
                            b.Rankings[0].Id);
        }
        public void RRBSetMatchWinner_FinishesMatch()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

            b.SetMatchWinner(1, PlayerSlot.Challenger);
            Assert.IsTrue(b.GetMatch(1).IsFinished);
        }
        public void RRBSetMatchWinner_AddsWinValueToRankings()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

            b.SetMatchWinner(1, PlayerSlot.Challenger);
            int rIndex = b.Rankings.FindIndex(r => r.Id == b.GetMatch(1).Players[(int)PlayerSlot.Challenger].Id);

            Assert.AreEqual(1, b.Rankings[rIndex].Wins);
        }