public void ConvertPouleToScore_PouleShouldOrderDrawsInCorrectOrder() { //Arrange List <Club> clubs = new List <Club> { testClub1, testClub2, testClub3, testClub4, testClub5, testClub6 }; List <Match> matches = new List <Match> { testMatch1, testMatch2, testMatch3, testMatch4, testMatch5, testMatch6, testMatch7, testMatch8, testMatch9, testMatch10, testMatch11, testMatch12, testMatch13, testMatch14, testMatch15 }; Poule poule = new Poule() { Clubs = clubs, Matches = matches }; //Act PouleScore result = PouleSimulator.ConvertPouleToScore(poule); //Assert Assert.Equal(testClub1, result.PouleScoreRows[0].Club); Assert.Equal(testClub2, result.PouleScoreRows[1].Club); Assert.Equal(testClub3, result.PouleScoreRows[2].Club); Assert.Equal(testClub4, result.PouleScoreRows[3].Club); Assert.Equal(testClub5, result.PouleScoreRows[4].Club); Assert.Equal(testClub6, result.PouleScoreRows[5].Club); }
private static void ApplyMatchToPouleScore(Match match, PouleScore score) { var homeClubScoreRow = score.PouleScoreRows.Find(i => object.ReferenceEquals(i.Club, match.HomeClub)); var awayClubScoreRow = score.PouleScoreRows.Find(i => object.ReferenceEquals(i.Club, match.AwayClub)); homeClubScoreRow.GoalsFor += match.HomeGoals; homeClubScoreRow.GoalsAgainst += match.AwayGoals; awayClubScoreRow.GoalsAgainst += match.HomeGoals; awayClubScoreRow.GoalsFor += match.AwayGoals; if (match.MatchResult == MatchResult.Home) { homeClubScoreRow.GamesWon++; awayClubScoreRow.GamesLost++; } else if (match.MatchResult == MatchResult.Away) { awayClubScoreRow.GamesWon++; homeClubScoreRow.GamesLost++; } else { homeClubScoreRow.GamesDrawn++; awayClubScoreRow.GamesDrawn++; } }
public void ConvertPouleToScore_PouleWithoutMatchesShouldReturnZeroSheet() { //Arrange List <Club> clubs = new List <Club> { testClub1, testClub2 }; Poule poule = new Poule(clubs); //Act PouleScore result = PouleSimulator.ConvertPouleToScore(poule); PouleScoreRow expectedResult = new PouleScoreRow(testClub1); //Assert Assert.Equal(expectedResult, result.PouleScoreRows[0]); }
public void ConvertPouleToScore_OneClubShouldReturnNoMatchesPlayed() { //Arrange List <Club> clubs = new List <Club>() { testClub1 }; Poule poule = new Poule(clubs); //Act PouleScore result = PouleSimulator.SimulatePoule(poule); //Assert Assert.Equal(result.PouleScoreRows[0].MatchesPlayed, 0); }
public static PouleScore ConvertPouleToScore(Poule poule) { PouleScore result = new PouleScore(); foreach (Club c in poule.Clubs) { result.PouleScoreRows.Add(new PouleScoreRow(c, poule)); } foreach (Match m in poule.Matches) { ApplyMatchToPouleScore(m, result); } result.PouleScoreRows.Sort(); return(result); }