public List<CupWinner> GetCupWinnersForSeason(Season season) { if(CupWinners == null) return new List<CupWinner>(); return CupWinners.Where(cw => cw.Season.Id == season.Id).ToList(); }
public List<LeagueWinner> GetLeagueWinnersForSeason(Season season) { if(LeagueWinners == null) return new List<LeagueWinner>(); return LeagueWinners.Where(lw => lw.League.Season.Id == season.Id).ToList(); }
public void CanGetSeasonToString() { Season season = new Season(2008, 2009); Assert.NotNull(season); Assert.That(season.ToString(), Is.EqualTo("2008/2009")); }
public void CanCreateTeamLeague() { string teamName = "Velocity"; string teamNameLong = "Nunthorpe Velocity"; Season season = new Season(2008, 2009); League league = new League(season, "Mens", 1, 1); Team team = new Team(teamName, teamNameLong); ; TeamLeague teamLeague = new TeamLeague(league, team, teamName, teamNameLong); Assert.IsNotNull(teamLeague); Assert.That(teamLeague.TeamName, Is.EqualTo(teamName)); Assert.That(teamLeague.TeamNameLong, Is.EqualTo(teamNameLong)); Assert.That(teamLeague.Team, Is.EqualTo(team)); Assert.That(teamLeague.League, Is.EqualTo(league)); // Assert defaults Assert.That(teamLeague.GamesLostAway, Is.EqualTo(0)); Assert.That(teamLeague.GamesLostHome, Is.EqualTo(0)); Assert.That(teamLeague.GamesLostTotal, Is.EqualTo(0)); Assert.That(teamLeague.GamesPct, Is.EqualTo(0)); Assert.That(teamLeague.GamesPlayed, Is.EqualTo(0)); Assert.That(teamLeague.GamesWonAway, Is.EqualTo(0)); Assert.That(teamLeague.GamesWonHome, Is.EqualTo(0)); Assert.That(teamLeague.GamesWonTotal, Is.EqualTo(0)); Assert.That(teamLeague.PointsAgainstPerGameAvg, Is.EqualTo(0)); Assert.That(teamLeague.PointsLeague, Is.EqualTo(0)); Assert.That(teamLeague.PointsScoredAgainst, Is.EqualTo(0)); Assert.That(teamLeague.PointsScoredDifference, Is.EqualTo(0)); Assert.That(teamLeague.PointsScoredFor, Is.EqualTo(0)); Assert.That(teamLeague.PointsScoredPerGameAvg, Is.EqualTo(0)); Assert.That(teamLeague.Streak, Is.EqualTo(null)); }
public League(Season season, string leagueDescription, int divisionNo, int displayOrder) : this() { Check.Require(season != null, "non null season must be provided"); //Check.Require(endYear.ToString().Length == 4, "endYear must have 4 characters. e.g. 2009"); this.Season = season; this.LeagueDescription = leagueDescription; this.DivisionNo = divisionNo; this.DisplayOrder = displayOrder; }
public CupWinner(Season season, Cup cup, Team team) : this() { Check.Require(season != null, "season must be provided"); Check.Require(cup != null, "cup must be provided"); Check.Require(team != null, "team must be provided"); this.Season = season; this.Cup = cup; this.Team = team; }
public void LeagueNameWithDivisionValid() { Season season = new Season(2008, 2009); ; string leagueDescription = "Mens"; int divisionNo = 1; int displayOrder = 2; League league = new League(season, leagueDescription, divisionNo, displayOrder); Assert.IsNotNull(league); Assert.That(league.ToString() == "Mens Division 1"); }
public void Setup() { user = new User(); season = new Season(2008, 2009); homeTeam = new Team("home", "homeTeam"); awayTeam = new Team("away", "awayTeam"); league = new League(season, "league desc", 1, 1); teamLeagueHome = new TeamLeague(league, homeTeam, "home", "homeTeam"); teamLeagueAway = new TeamLeague(league, awayTeam, "away", "awayTeam"); player = new Player("Phil", "Hale"); fixtureDate = DateTime.Today; fixture = new Fixture(teamLeagueHome, teamLeagueAway, fixtureDate, user); }
public void CanCreateSeason() { int startYear = 2008; int endYear = 2009; Season season = new Season(startYear, endYear); Assert.IsNotNull(season); Assert.That(season.StartYear, Is.EqualTo(startYear)); Assert.That(season.EndYear, Is.EqualTo(endYear)); Assert.AreEqual(season.StartYear.ToString().Length, 4); Assert.AreEqual(season.EndYear.ToString().Length, 4); }
public void CanCreateLeague() { Season season = new Season(2008, 2009); ; string leagueDescription = "Mens Division"; int divisionNo = 1; int displayOrder = 2; League league = new League(season, leagueDescription, divisionNo, displayOrder); Assert.IsNotNull(league); Assert.That(league.Season.Id == season.Id); Assert.That(league.LeagueDescription == leagueDescription); Assert.That(league.DivisionNo == divisionNo); Assert.That(league.DisplayOrder == displayOrder); }
public PlayerSeasonStats(Player player, Season season, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards) : this() { // Check for required values Check.Require(player != null, "player must be provided"); Check.Require(season != null, "season must be provided"); this.Season = season; this.Player = player; UpdateStats(totalPoints, totalFouls, gamesPlayed, mvpAwards); }
public PlayerLeagueStats(Player player, Season season, League league, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards) : this() { Check.Require(player != null, "player must be provided"); Check.Require(season != null, "season must be provided"); Check.Require(league != null, "league must be provided"); this.Season = season; this.Player = player; this.League = league; UpdateStats(totalPoints, totalFouls, gamesPlayed, mvpAwards); }
public void CanCreatePlayerSeasonStatsWithZeroGamesPlayed() { Season season = new Season(2009, 2010); Player player = new Player("Phil", "Hale"); int totalPoints = -2; int totalFouls = 2; int gamesPlayed = 0; int mvpAwards = 5; PlayerSeasonStats stats = new PlayerSeasonStats(player, season, totalPoints, totalFouls, gamesPlayed, mvpAwards); Assert.IsNotNull(stats); Assert.That(stats.Season, Is.EqualTo(season)); Assert.That(stats.Player, Is.EqualTo(player)); Assert.That(stats.GamesPlayed, Is.EqualTo(0)); Assert.That(stats.TotalPoints, Is.EqualTo(0)); Assert.That(stats.PointsPerGame, Is.EqualTo(0)); Assert.That(stats.TotalFouls, Is.EqualTo(0)); Assert.That(stats.FoulsPerGame, Is.EqualTo(0)); Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards)); }
public void Init() { season = new Season(2009, 2010); player = new Player("Phil", "Hale"); league = new League(season, "Mens", 1, 1); }
public void Dispose() { season = null; player = null; league = null; }
public ActionResult Edit(Season @season) { if (ModelState.IsValid) { seasonService.Update(@season); seasonService.Commit(); SuccessMessage(FormMessages.SaveSuccess); return RedirectToAction("Index"); } return View(@season); }
public PlayerSeasonStats UpdatePlayerSeasonStats(PlayerFixture playerFixture, Season season) { PlayerSeasonStats playerSeasonStats; int totalPoints = 0; int totalFouls = 0; int mvpAwards = 0; // Get all PlayerFixture records for specified season List<PlayerFixture> playerFixturesForSeason = this.statsReportingService.GetPlayerFixtureStatsForSeason(playerFixture.Player.Id, season.Id).ToList(); // Total stats foreach (PlayerFixture pf in playerFixturesForSeason) { totalPoints += pf.PointsScored; totalFouls += pf.Fouls; if (pf.IsMvp == "Y") mvpAwards++; } // Find existing record playerSeasonStats = this.statsReportingService.GetPlayerSeasonStats(playerFixture.Player.Id, season.Id); // If doesn't exist, create new if (playerSeasonStats == null) playerSeasonStats = new PlayerSeasonStats(playerFixture.Player, season, totalPoints, totalFouls, playerFixturesForSeason.Count, mvpAwards); else { // Update values playerSeasonStats.UpdateStats(totalPoints, totalFouls, playerFixturesForSeason.Count, mvpAwards); } // Save matchResultRepository.SavePlayerSeasonStats(playerSeasonStats); return playerSeasonStats; }
private League AddLeague(Season season, string leagueDescription) { League league = new League(season, leagueDescription, 1, 1); //league = seasonRepository.SaveOrUpdateLeague(league); //FlushSessionAndEvict(league); return league; //Console.WriteLine("league id = " + league.Id + " - season id " + league.Season.Id); }
public LeagueWinnerTests() { season = new Season(2008, 2009); league = new League(season, "My League", 1, 1); team = new Team("Velocity", "Nunthorpe Velocity"); }
public void Teardown() { season = null; team = null; league = null; }
public void Setup() { season = new Season(2008, 2009); team = new Team("name", "name"); league = new League(season, "league desc", 1, 1); }
public PlayerCupStats UpdatePlayerCupStats(PlayerFixture playerFixture, Cup cup, Season season) { PlayerCupStats playerCupStats; // Get all PlayerFixture records for specified season List<PlayerFixture> playerFixturesForCup = statsReportingService.GetPlayerFixtureStatsForCupAndSeason(playerFixture.Player.Id, cup.Id, season.Id).ToList(); // Total stats int totalPoints = playerFixturesForCup.Sum(pf => pf.PointsScored); int totalFouls = playerFixturesForCup.Sum(pf => pf.Fouls); int mvpAwards = playerFixturesForCup.Count(pf => pf.IsMvp == "Y"); // Find existing record playerCupStats = statsReportingService.GetPlayerCupStats(playerFixture.Player.Id, cup.Id, season.Id); // If doesn't exist, create new if (playerCupStats == null) playerCupStats = new PlayerCupStats(playerFixture.Player, cup, season, totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards); else { // Update values playerCupStats.UpdateStats(totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards); } // Save matchResultRepository.SavePlayerCupStats(playerCupStats); return playerCupStats; }
public void UpdatePlayerCupStats(List<PlayerFixture> playerFixtures, Cup cup, Season season) { foreach (PlayerFixture pf in playerFixtures) UpdatePlayerCupStats(pf, cup, season); }
public void InsertSeason(Season season) { seasonRepository.Insert(season); }
protected PlayerSeasonStats AddPlayerSeasonStats(Player player, Season season, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards) { PlayerSeasonStats stats = new PlayerSeasonStats(player, season, totalPoints, totalFouls, gamesPlayed, mvpAwards); //statsRepository.SaveOrUpdatePlayerSeasonStats(stats); //FlushSessionAndEvict(stats); return stats; }
public void Setup() { user = new User(); season = new Season(2008, 2009); homeTeam = new Team("home", "homeTeam"); homeTeam.Id = 1; awayTeam = new Team("away", "awayTeam"); awayTeam.Id = 2; league = new League(season, "league desc", 1, 1); homeTeamLeague = new TeamLeague(league, homeTeam, "home", "homeTeam"); awayTeamLeague = new TeamLeague(league, awayTeam, "away", "awayTeam"); fixtureDate = DateTime.Today; }
private Season AddSeason(int startYear, int endYear) { Season season = new Season(startYear, endYear); //season = seasonRepository.SaveOrUpdate(season); //FlushSessionAndEvict(season); return season; }
public void Teardown() { season = null; homeTeam = null; homeTeam = null; league = null; teamLeagueHome = null; teamLeagueAway = null; fixture = null; }
public void UpdatePlayerSeasonStats_PlayersInListAndNoExistingRecord_Success() { PlayerFixture playerFixture = new PlayerFixture() { Player = new Player() { Id = 10 } }; Season season = new Season() { Id = 5 }; this.mockStatsReportingService.GetPlayerFixtureStatsForSeason(playerFixture.Player.Id, season.Id).Returns(PlayerFixturesWithStats); this.mockStatsReportingService.GetPlayerSeasonStats(playerFixture.Player.Id, season.Id).Returns((PlayerSeasonStats)null); var returnValue = matchResultService.UpdatePlayerSeasonStats(playerFixture, season); Assert.That(returnValue, Is.Not.Null); Assert.That(returnValue.GamesPlayed, Is.EqualTo(PlayerFixturesWithStatsGamesPlayed)); Assert.That(returnValue.TotalPoints, Is.EqualTo(PlayerFixturesWithStatsTotalPoints)); Assert.That(returnValue.TotalFouls, Is.EqualTo(PlayerFixturesWithStatsTotalFouls)); Assert.That(returnValue.MvpAwards, Is.EqualTo(PlayerFixturesWithStatsMvpAwards)); Assert.That(returnValue.PointsPerGame, Is.EqualTo(PlayerFixturesWithStatsPointsPerGame)); Assert.That(returnValue.FoulsPerGame, Is.EqualTo(PlayerFixturesWithStatsFoulsPerGame)); this.mockMatchResultRepository.Received().SavePlayerSeasonStats(returnValue); }
public void UpdatePlayerSeasonStats(List<PlayerFixture> playerFixtures, Season season) { foreach (PlayerFixture pf in playerFixtures) UpdatePlayerSeasonStats(pf, season); }