Esempio n. 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);
        }
Esempio n. 2
0
        public void TestRound1()
        {
            var bracket = new Bracket();

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

            bracket.CreateNextRound();

            Assert.AreEqual(1, bracket.RoundNumber);
            Assert.AreEqual(8, bracket.Teams.Count);
            Assert.AreEqual(1, bracket.Rounds.Count);
            Assert.AreEqual(false, bracket.IsComplete());
            Assert.AreEqual(null, bracket.FindChampion());

            var round = bracket.Rounds[0];

            Assert.AreEqual(4, round.Games.Count);

            Assert.AreEqual("UCLA", round.Games[0].HomeTeam.Name);
            Assert.AreEqual("UNLV", round.Games[0].AwayTeam.Name);
            Assert.AreEqual(null, round.Games[0].Winner);

            Assert.AreEqual("USC", round.Games[1].HomeTeam.Name);
            Assert.AreEqual("California", round.Games[1].AwayTeam.Name);
            Assert.AreEqual(null, round.Games[1].Winner);

            Assert.AreEqual("Missouri", round.Games[2].HomeTeam.Name);
            Assert.AreEqual("Tennessee", round.Games[2].AwayTeam.Name);
            Assert.AreEqual(null, round.Games[2].Winner);

            Assert.AreEqual("Florida", round.Games[3].HomeTeam.Name);
            Assert.AreEqual("Houston", round.Games[3].AwayTeam.Name);
            Assert.AreEqual(null, round.Games[3].Winner);
        }