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

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

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

            int expectedAffected = 6;
            int affectedMatches  = 0;

            b.MatchesModified += delegate(object sender, BracketEventArgs e)
            {
                affectedMatches = e.UpdatedMatches.Count;
            };

            b.ResetMatchScore(1);
            Assert.AreEqual(expectedAffected, affectedMatches);
        }
        public void DEBResetMatches_FiresMatchesModifiedEvent_WithAllAffectedMatches()
        {
            List <IPlayer> pList = new List <IPlayer>();

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

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

            int matchesAffected = -1;

            b.MatchesModified += delegate(object sender, BracketEventArgs e)
            {
                matchesAffected = e.UpdatedMatches
                                  .Select(mm => mm.MatchNumber).Distinct().ToList().Count;
            };
            b.ResetMatches();
            Assert.AreEqual(b.NumberOfMatches, matchesAffected);
        }
        public void DEBAddGame_ThrowsMatchesModifiedEvent_IncludesLowerRoundAdvancement()
        {
            int affectedMatches = 0;

            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.SetMatchWinner(1, PlayerSlot.Defender);
            b.SetMatchWinner(2, PlayerSlot.Defender);

            b.MatchesModified += delegate(object sender, BracketEventArgs e)
            {
                affectedMatches = e.UpdatedMatches.Count;
            };
            b.AddGame(b.GetLowerRound(1)[0].MatchNumber, 3, 2, PlayerSlot.Defender);
            Assert.AreEqual(2, affectedMatches);
        }