public void LadderTierAllMatchesNotPlayed() { var lt = new LadderTier(); var totalTeams = 16; var teamIDs = GetTeamIDs(totalTeams); lt.GenerateRandomMatches(teamIDs); Assert.IsFalse(lt.AllMatchesPlayed()); }
public void GenerateLadder() { tierCount = LadderUtil.GetTierCount(teamCount); ladderTiers = new LadderTier[tierCount]; for (int i = 0; i < tierCount; i++) { ladderTiers[i] = new LadderTier(); } ladderTiers[currentTier].GenerateRandomMatches(teamIDs); }
public void LadderTierExactLadderTest() { var lt = new LadderTier(); var totalTeams = 16; var teamIDs = GetTeamIDs(totalTeams); var testIds = GetTeamIDs(totalTeams); lt.GenerateRandomMatches(teamIDs); var matches = lt.GetAllMatches(); foreach (var match in matches.Values) { Assert.IsTrue(testIds.Contains(match.GetTeamAID())); Assert.IsTrue(testIds.Contains(match.GetTeamBID())); } Assert.AreEqual(8, matches.Count); }
public void LadderTierAddMatches() { var lt = new LadderTier(); var matchCounter = 0; var teamAID = 3; var teamBID = 2; lt.AddTeam(3,matchCounter++); lt.AddTeam(2,matchCounter++); var matches = lt.GetAllUnplayedMatches(); foreach(var match in matches.Values) { Assert.AreEqual(teamAID, match.GetTeamAID()); Assert.AreEqual(teamBID, match.GetTeamBID()); } }
public LadderTier Clone() { var clone = new LadderTier(); var ts = new List<int>(); foreach (var team in currentTeams) { ts.Add(team); } clone.currentTeams = ts; var mr = new Dictionary<int, MatchResult>(); foreach (var match in matches) { mr.Add(match.Key, match.Value.Clone()); } clone.SetMatches(mr); return clone; }
public void LadderTierAllMatchesPlayed() { var lt = new LadderTier(); var totalTeams = 16; var teamIDs = GetTeamIDs(totalTeams); lt.GenerateRandomMatches(teamIDs); var matches = lt.GetAllMatches(); var scoreA = new Score(); scoreA.AddFlag(); var scoreB = new Score(); scoreB.AddTag(); foreach (var match in matches) { var key = match.Key; var value = match.Value; var teamAID = match.Value.GetTeamAID(); value.SetTeamAScore(scoreA); value.SetTeamBScore(scoreB); lt.SetMatch(key, value); Assert.AreEqual(teamAID, lt.GetWinner(key)); } Assert.IsTrue(lt.AllMatchesPlayed()); }
public void LadderTierUnplayedMatches() { var lt = new LadderTier(); var totalTeams = 16; var teamIDs = GetTeamIDs(totalTeams); lt.GenerateRandomMatches(teamIDs); var matches = lt.GetAllMatches(); var scoreA = new Score(); scoreA.AddFlag(); var scoreB = new Score(); scoreB.AddTag(); int i = 0; foreach (var match in matches) { if (i == 4) { break; } var key = match.Key; var value = match.Value; var teamAID = match.Value.GetTeamAID(); value.SetTeamAScore(scoreA); value.SetTeamBScore(scoreB); lt.SetMatch(key, value); Assert.AreEqual(teamAID, lt.GetWinner(key)); i++; } var played = lt.GetAllUnplayedMatches(); Assert.AreEqual(4, played.Count); }