public void given_week_two_when_determining_team_handicap_then_use_current_averages()
        {
            Team team1 = CreateTeam("team1");
            Team team2 = CreateTeam("team2");
            Player player1 = CreatePlayer("M", 1, "player1", team1, 150);
            Player player2 = CreatePlayer("M", 2, "player2", team1, 150);
            Player player3 = CreatePlayer("M", 3, "player3", team2, 200);
            Player player4 = CreatePlayer("M", 4, "player4", team2, 200);
            List<Player> playersOnTeam1 = new List<Player> { player1, player2 };
            List<Player> playersOnTeam2 = new List<Player> { player3, player4 };
            Week week = CreateWeek(1, "week 1");
            WeeklyScore scoreForPlayer1 = CreateWeeklyScore(100, 110, 120, player1, player1.Team, week, false);
            WeeklyScore scoreForPlayer2 = CreateWeeklyScore(100, 110, 120, player2, player2.Team, week, false);
            WeeklyScore scoreForPlayer3 = CreateWeeklyScore(200, 210, 220, player3, player3.Team, week, false);
            WeeklyScore scoreForPlayer4 = CreateWeeklyScore(200, 210, 220, player4, player4.Team, week, false);
            List<WeeklyScore> scores = new List<WeeklyScore> { scoreForPlayer1, scoreForPlayer2, scoreForPlayer3, scoreForPlayer4 };

            Handicap handicap = new Handicap();
            TeamStats teamStats = new TeamStats();
            double team1Average = teamStats.GetTeamAverage(scores, playersOnTeam1);
            double team2Average = teamStats.GetTeamAverage(scores, playersOnTeam2);

            double team1Handicap = handicap.GetHandicap(team1Average, team2Average);
            double team2Handicap = handicap.GetHandicap(team2Average, team1Average);

            Assert.That(team1Handicap, Is.EqualTo(200));
            Assert.That(team2Handicap, Is.EqualTo(0));
        }
        /// <summary>
        /// Gets the team data for matchup for the scores provided up to the week number specified. Does not include the current week number.
        /// </summary>
        /// <param name="team1Players">The team1Players.</param>
        /// <param name="team2Players">The team2 players.</param>
        /// <param name="scores">The scores.</param>
        /// <param name="weekNumber">The week number.</param>
        /// <returns></returns>
        public MatchupReportTeamData GetTeamDataForMatchup(List<Player> team1Players, List<Player> team2Players, IEnumerable<WeeklyScore> scores, int weekNumber)
        {
            Team team1 = team1Players[0].Team;
            Team team2 = team2Players[0].Team;
            List<WeeklyScore> scoresForTeam1 = GetScoresToWeek(scores, weekNumber, team1);
            List<WeeklyScore> scoresForTeam2 = GetScoresToWeek(scores, weekNumber, team2);
            TeamStats teamAverage = new TeamStats();
            Handicap handicap = new Handicap();
            double team1Average = teamAverage.GetTeamAverage(scoresForTeam1, team1Players);
            double team2Average = teamAverage.GetTeamAverage(scoresForTeam2, team2Players);
            double team1Handicap = handicap.GetHandicap(team1Average, team2Average);// team1Average < team2Average ? team2Average - team1Average : 0;
            double team2Handicap = handicap.GetHandicap(team2Average, team1Average);// team2Average < team1Average ? team1Average - team2Average : 0;

            return new MatchupReportTeamData(team1, team1Players, team1Average, team1Handicap, team2, team2Players, team2Average, team2Handicap);
        }
        public void given_week_one_when_determining_team_handicap_then_use_initial_averages()
        {
            Team team1 = CreateTeam("team 1");
            Team team2 = CreateTeam("team 2");
            Player player1 = CreatePlayer("M", 1, "player 1", team1, 100);
            Player player2 = CreatePlayer("M", 2, "player 2", team1, 100);
            Player player3 = CreatePlayer("M", 3, "player 3", team2, 110);
            Player player4 = CreatePlayer("M", 4, "player 4", team2, 110);
            List<Player> team1Players = new List<Player>() {player1, player2};
            List<Player> team2Players = new List<Player>() {player3, player4};
            Handicap handicap = new Handicap();
            TeamStats teamStats = new TeamStats();
            double team1Average = teamStats.GetTeamAverage(new List<WeeklyScore>(), team1Players);
            double team2Average = teamStats.GetTeamAverage(new List<WeeklyScore>(), team2Players);

            double team1Handicap = handicap.GetHandicap(team1Average, team2Average);
            double team2Handicap = handicap.GetHandicap(team2Average, team1Average);

            Assert.That(team1Handicap, Is.EqualTo(20));
            Assert.That(team2Handicap, Is.EqualTo(0));
        }
Exemple #4
0
        private double GetTeamAveragePriorToTheStartOfTheWeek(IEnumerable<WeeklyScore> weeklyScores, IEnumerable<Player> players, Week week)
        {
            TeamStats teamStats = new TeamStats();
            double average = teamStats.GetTeamAverage(weeklyScores, players, week.WeekNumber - 1);

            return average;
        }