public void TestCreateNextRoundBeforeComplete() { 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.CreateNextRound(); bracket.Rounds[0].Games[0].Resolve(bracket.Teams["USC"]); // California vs UNLV is still unresolved. Assert.ThrowsException <Exception>(() => bracket.CreateNextRound()); }
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); }
public void TestUnevenTeamsPerRegion() { var bracket = new Bracket(); bracket.AddTeam("UCLA", 1, "North"); bracket.AddTeam("USC", 2, "South"); bracket.AddTeam("California", 3, "West"); Assert.ThrowsException <Exception>(() => bracket.CreateNextRound()); }
public void TestUnevenTeams() { 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, "West"); Assert.ThrowsException <Exception>(() => bracket.CreateNextRound()); }
public void TestFinalsRound2() { 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(); Assert.AreEqual(3, bracket.RoundNumber); Assert.AreEqual(8, bracket.Teams.Count); Assert.AreEqual(3, bracket.Rounds.Count); Assert.AreEqual(false, bracket.IsComplete()); Assert.AreEqual(null, bracket.FindChampion()); var round = bracket.Rounds[2]; Assert.AreEqual(1, round.Games.Count); Assert.AreEqual("UCLA", round.Games[0].HomeTeam.Name); Assert.AreEqual("Missouri", round.Games[0].AwayTeam.Name); Assert.AreEqual(null, round.Games[0].Winner); }