Exemple #1
0
        public void TestComplete()
        {
            var bracket = new Bracket();

            bracket.AddTeam("UCLA", 1, "North");
            bracket.AddTeam("USC", 2, "North");
            bracket.AddTeam("California", 3, "West");
            bracket.AddTeam("UNLV", 4, "West");
            bracket.AddTeam("Missouri", 5, "South");
            bracket.AddTeam("Florida", 6, "South");
            bracket.AddTeam("Houston", 7, "East");
            bracket.AddTeam("Tennessee", 8, "East");

            bracket.CreateNextRound();
            bracket.Rounds[0].Games[0].Resolve(bracket.Teams["UCLA"]);
            bracket.Rounds[0].Games[1].Resolve(bracket.Teams["California"]);
            bracket.Rounds[0].Games[2].Resolve(bracket.Teams["Missouri"]);
            bracket.Rounds[0].Games[3].Resolve(bracket.Teams["Houston"]);

            bracket.CreateNextRound();
            bracket.Rounds[1].Games[0].Resolve(bracket.Teams["UCLA"]);
            bracket.Rounds[1].Games[1].Resolve(bracket.Teams["Missouri"]);

            bracket.CreateNextRound();
            bracket.Rounds[2].Games[0].Resolve(bracket.Teams["Missouri"]);

            Assert.AreEqual(3, bracket.RoundNumber);
            Assert.AreEqual(8, bracket.Teams.Count);
            Assert.AreEqual(3, bracket.Rounds.Count);
            Assert.AreEqual(true, bracket.IsComplete());
            Assert.AreEqual(bracket.Teams["Missouri"], bracket.FindChampion());

            var games = bracket.ListGames(bracket.Teams["Missouri"]);

            Assert.AreEqual(3, games.Count);

            Assert.AreEqual(1, games[0].RoundNumber);
            Assert.AreEqual("Missouri", games[0].Winner?.Name);
            Assert.AreEqual("Florida", games[0].Loser?.Name);

            Assert.AreEqual(2, games[1].RoundNumber);
            Assert.AreEqual("Missouri", games[1].Winner?.Name);
            Assert.AreEqual("California", games[1].Loser?.Name);

            Assert.AreEqual(3, games[2].RoundNumber);
            Assert.AreEqual("Missouri", games[2].Winner?.Name);
            Assert.AreEqual("UCLA", games[2].Loser?.Name);
        }