Esempio n. 1
0
        public void GetOpponents()
        {
            var startDivision = BaseballScheduleHelper.GetRandomDivision();
            var teams         = BaseballScheduleHelper.GetLeagueTeamsByDivision(League.Circuit.NL, startDivision)
                                .ToList();
            var team      = BaseballScheduleHelper.GetRandomTeamFromList(teams);
            var opponents = BaseballScheduleHelper.GetDivisionOpponents(team, teams);

            Assert.IsTrue(opponents.All(t => !t.Equals(team)));
        }
Esempio n. 2
0
        public void GetDivisionTeams()
        {
            var division = BaseballScheduleHelper.GetRandomDivision();
            var teams    = BaseballScheduleHelper.GetLeagueTeamsByDivision(League.Circuit.NL, division)
                           .ToList();
            var team      = BaseballScheduleHelper.GetRandomTeamFromList(teams);
            var opponents = BaseballScheduleHelper.GetDivisionOpponents(team, teams).ToList();

            Assert.IsTrue(
                teams.Count == 5 &&
                team.Division == division &&
                teams.Count - opponents.Count == 1 &&
                opponents.All(t => !t.Equals(team)));
        }
Esempio n. 3
0
        public void ScheduleDivisionTeams()
        {
            var scheduledSeries = new SeriesData();
            var startDivision   = BaseballScheduleHelper.GetRandomDivision();
            var teams           = BaseballScheduleHelper.GetLeagueTeamsByDivision(League.Circuit.NL, startDivision);
            var team            = BaseballScheduleHelper.GetRandomTeamFromList(teams);
            var opponents       = BaseballScheduleHelper.GetDivisionOpponents(team, teams);

            var scheduledGames = ScheduleGenerator.ScheduleDivisionSeries(scheduledSeries, team, teams, opponents);
            var awayGames      = from t in scheduledGames.GamesInSchedule
                                 where t.AwayTeam == team
                                 group t by t.AwayTeam
                                 into a
                                 select a.Count();

            var homeGames = from t in scheduledGames.GamesInSchedule
                            where t.HomeTeam == team
                            group t by t.HomeTeam
                            into h
                            select h.Count();

            var opponentGamesAway = from t in scheduledGames.GamesInSchedule
                                    where t.AwayTeam == team
                                    group t by t.HomeTeam
                                    into a
                                    select a.Count();

            var opponentGamesHome = from t in scheduledGames.GamesInSchedule
                                    where t.HomeTeam == team
                                    group t by t.AwayTeam
                                    into a
                                    select a.Count();

            //TODO: Assert scheduled team has played each opponent 19 times
            Assert.IsTrue(awayGames.First() == 38 && homeGames.First() == 38);     //Scheduled team should have 38 division home games and 38 division away games
            Assert.IsTrue(scheduledGames.GamesInSchedule.Count == 76);             //Total division games scheduled for team should be 76
        }