Exemplo n.º 1
0
        public virtual List <CompetitionTeam> GetTeams(Season season, Team team, SeasonDivisionRule divisionRule)
        {
            var teams = new List <CompetitionTeam>();

            if (team != null)
            {
                teams.Add(season.Teams.Where(t => t.Parent.Id == team.Id).First());
            }
            else if (divisionRule != null)
            {
                teams.AddRange(season.GetAllTeamsInDivision(season.GetDivisionByName(divisionRule.DivisionName)));
            }
            else
            {
                return(null);
            }

            return(teams);
        }
Exemplo n.º 2
0
        public void ShouldGetAllTeamsInDivision()
        {
            var season = new Season();
            var nhl    = new SeasonDivision()
            {
                Season = season, Name = "NHL", Level = 1
            };
            var eastern = new SeasonDivision()
            {
                Season = season, Name = "Eastern", ParentDivision = nhl, Level = 2
            };
            var western = new SeasonDivision()
            {
                Season = season, Name = "Western", ParentDivision = nhl, Level = 2
            };
            var central = new SeasonDivision()
            {
                Season = season, Name = "Central", ParentDivision = nhl, Level = 2
            };
            var east = new SeasonDivision()
            {
                Season = season, Name = "East", ParentDivision = eastern, Level = 3
            };
            var atlantic = new SeasonDivision()
            {
                Season = season, Name = "Atlantic", ParentDivision = eastern, Level = 3
            };
            var west = new SeasonDivision()
            {
                Season = season, Name = "West", ParentDivision = western, Level = 3
            };
            var northwest = new SeasonDivision()
            {
                Season = season, Name = "NorthWest", ParentDivision = west, Level = 4
            };
            var southwest = new SeasonDivision()
            {
                Season = season, Name = "Northeast", ParentDivision = west, Level = 4
            };

            season.Divisions = new List <SeasonDivision>()
            {
                nhl, eastern, western, central, east, atlantic, west, northwest, southwest
            };
            var teamList = new List <SeasonTeam>()
            {
                CreateSeasonTeam(season, 1, "Team 1", nhl),
                CreateSeasonTeam(season, 2, "Team 2", eastern),
                CreateSeasonTeam(season, 3, "Team 3", east),
                CreateSeasonTeam(season, 4, "Team 4", east),
                CreateSeasonTeam(season, 5, "Team 5", east),
                CreateSeasonTeam(season, 6, "Team 6", northwest),
                CreateSeasonTeam(season, 7, "Team 7", northwest),
                CreateSeasonTeam(season, 8, "Team 8", central),
                CreateSeasonTeam(season, 9, "Team 9", central),
                CreateSeasonTeam(season, 10, "Team 10", atlantic),
                CreateSeasonTeam(season, 11, "Team 11", atlantic),
                CreateSeasonTeam(season, 12, "Team 12", atlantic),
                CreateSeasonTeam(season, 13, "Team 13", atlantic),
                CreateSeasonTeam(season, 14, "Team 14", northwest),
                CreateSeasonTeam(season, 15, "Team 15", southwest),
                CreateSeasonTeam(season, 16, "Team 16", southwest)
            };

            StrictEqual(16, season.GetAllTeamsInDivision(nhl).Count);
            StrictEqual(8, season.GetAllTeamsInDivision(eastern).Count);
            StrictEqual(5, season.GetAllTeamsInDivision(western).Count);
            StrictEqual(2, season.GetAllTeamsInDivision(central).Count);
            StrictEqual(4, season.GetAllTeamsInDivision(atlantic).Count);
            StrictEqual(3, season.GetAllTeamsInDivision(east).Count);
            StrictEqual(5, season.GetAllTeamsInDivision(west).Count);
            StrictEqual(3, season.GetAllTeamsInDivision(northwest).Count);
            StrictEqual(2, season.GetAllTeamsInDivision(southwest).Count);
        }