示例#1
0
 private Player CreatePlayer(string gender, int id, string name, Team team, double initialAverage)
 {
     Player player = A.Fake<Player>();
     player.Gender = gender;
     player.Id = id;
     player.Name = name;
     player.Team = team;
     player.InitialAverage = initialAverage;
     return player;
 }
示例#2
0
        public void UpdatePointsForTeam(IEnumerable<WeeklyScore> team1Scores, IEnumerable<WeeklyScore> team2Scores,
                                        Week currentWeek, Team team1, Team team2, IEnumerable<Player> players)
        {
            List<Player> team1Players = players.Where(p => p.Team.Equals(team1)).ToList();
            IEnumerable<Player> team2Players = players.Where(p => p.Team.Equals(team2));
            double team1Average = GetTeamAveragePriorToTheStartOfTheWeek(team1Scores, team1Players, currentWeek);
            double team2Average = GetTeamAveragePriorToTheStartOfTheWeek(team2Scores, team2Players, currentWeek);
            Handicap handicap = new Handicap();
            double team1Handicap = handicap.GetHandicap(team1Average, team2Average);
            double team2Handicap = handicap.GetHandicap(team2Average, team1Average);

            double team1Points = 0;
            double team2Points = 0;

            double team1Game1 = team1Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game1);
            double team1Game2 = team1Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game2);
            double team1Game3 = team1Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game3);
            double team1Total = team1Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Total);
            double team2Game1 = team2Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game1);
            double team2Game2 = team2Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game2);
            double team2Game3 = team2Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Game3);
            double team2Total = team2Scores.Where(s => s.Week.WeekNumber == currentWeek.WeekNumber).Sum(s => s.Total);

            CalculatePointsPerRule(team1Game1, team1Handicap, team2Game1, team2Handicap, ref team1Points,
                                   ref team2Points);
            CalculatePointsPerRule(team1Game2, team1Handicap, team2Game2, team2Handicap, ref team1Points,
                                   ref team2Points);
            CalculatePointsPerRule(team1Game3, team1Handicap, team2Game3, team2Handicap, ref team1Points,
                                   ref team2Points);
            CalculatePointsPerRule(team1Total, team1Handicap*3, team2Total, team2Handicap*3, ref team1Points,
                                   ref team2Points);

            WeeklyPoint team1WeeklyPoint = team1.WeeklyPoints.FirstOrDefault(wp => wp.Week.Equals(currentWeek));
            WeeklyPoint team2WeeklyPoint = team2.WeeklyPoints.FirstOrDefault(wp => wp.Week.Equals(currentWeek));

            if (team1WeeklyPoint != null)
            {
                team1WeeklyPoint.Points = team1Points;
            }
            else
            {
                team1WeeklyPoint = new WeeklyPoint {Points = team1Points, Week = currentWeek};
                team1.WeeklyPoints.Add(team1WeeklyPoint);
            }

            if (team2WeeklyPoint != null)
            {
                team2WeeklyPoint.Points = team2Points;
            }
            else
            {
                team2WeeklyPoint = new WeeklyPoint {Points = team2Points, Week = currentWeek};
                team2.WeeklyPoints.Add(team2WeeklyPoint);
            }
        }
 public MatchupReportTeamData(Team team1, List<Player> team1Players, double team1Average, double team1Handicap, Team team2, List<Player> team2Players, double team2Average, double team2Handicap)
 {
     Team1 = team1;
     Team1Players = team1Players;
     Team1Average = team1Average;
     Team1Handicap = team1Handicap;
     Team2 = team2;
     Team2Players = team2Players;
     Team2Average = team2Average;
     Team2Handicap = team2Handicap;
 }
示例#4
0
 public bool Equals(Team other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     return Equals(other.Name, Name);
 }
        private WeeklyScore CreateWeeklyScore(int game1, int game2, int game3, Player player, Team team, Week week)
        {
            WeeklyScore score = A.Fake<WeeklyScore>();
            score.Game1 = game1;
            score.Game2 = game2;
            score.Game3 = game3;
            score.Player = player;
            score.Team = team;
            score.Week = week;

            return score;
        }
示例#6
0
 private List<WeeklyScore> GetScoresToWeek(IEnumerable<WeeklyScore> allScores, int weekNumber, Team team)
 {
     IEnumerable<WeeklyScore> scores =
         allScores.Where(weeklyScore => weeklyScore.Week.WeekNumber < weekNumber && weeklyScore.Team.Equals(team));
     return scores.ToList();
 }
 private void UpdateSelectedTeam(Team selectedTeam)
 {
     TeamName = selectedTeam.Name;
 }
示例#8
0
 public void GivenANewTeamWhenAddingTheTeamToTheLeagueThentheWeeklyPointsWillBeInitializedToEmptyList()
 {
     var team = new Team("adamo");
     Assert.NotNull(team.WeeklyPoints);
     Assert.IsTrue(team.WeeklyPoints.Count == 0);
 }