public void PrintAverages()
        {
            PlayerStats playerAverage = new PlayerStats();

            List<WeeklyScore> scoresPriorToThisWeek = _allScores.Where(s => s.Week.WeekNumber < SelectedWeek.WeekNumber).ToList();
            List<PlayerAveragesReportData> playerAveragesReportDatas = (from player in _players
                                                                        let average = playerAverage.GetPlayerAverage(player, scoresPriorToThisWeek)
                                                                        let totalPins = playerAverage.GetTotalPinsForPlayer(player, scoresPriorToThisWeek)
                                                                        let totalGames = playerAverage.GetTotalGamesForPlayer(player, scoresPriorToThisWeek)
                                                                        let gamesBetween200And250 = playerAverage.GetTotalGamesWithPinsBetween200And250ForPlayer(player, scoresPriorToThisWeek)
                                                                        let gamesGreaterThanOrEqualTo250 = playerAverage.GetTotalGamesWithPinsOver250ForPlayer(player, scoresPriorToThisWeek)
                                                                        select new PlayerAveragesReportData(player.Name, average, totalPins, totalGames, gamesBetween200And250, gamesGreaterThanOrEqualTo250, player.Team.Name)).ToList();

            List<TeamAveragesReportData> teamAveragesReportData = (from currentTeam in _teams
                                                                   let playersForTeam = _players.Where(p => p.Team.Equals(currentTeam)).ToList()
                                                                   let teamAverage = playersForTeam.Sum(player => playerAverage.GetPlayerAverage(player, scoresPriorToThisWeek))
                                                                   where currentTeam.Name != "Sub"
                                                                   select new TeamAveragesReportData(currentTeam.Name, teamAverage)).ToList();

            new PrintAveragesReport().Print(playerAveragesReportDatas, teamAveragesReportData);
        }
示例#2
0
 public void given_a_player_when_all_scores_are_supplied_then_get_only_total_pins_over_250_in_which_the_player_is_not_absent()
 {
     Team team1 = CreateTeam("team1");
     Player player1 = CreatePlayer("M", 1, "player1", team1, 150);
     Week week1 = CreateWeek(1, "week 1");
     Week week2 = CreateWeek(2, "week 2");
     WeeklyScore week1Score = CreateWeeklyScore(110, 255, 204, player1, team1, week1, false);
     WeeklyScore week2Score = CreateWeeklyScore(155, 212, 255, player1, team1, week2, true);
     List<WeeklyScore> scores = new List<WeeklyScore>() { week1Score, week2Score };
     PlayerStats playerAverage = new PlayerStats();
     int totalPins = playerAverage.GetTotalGamesWithPinsOver250ForPlayer(player1, scores);
     Assert.That(totalPins, Is.EqualTo(1));
 }