public void CanGetPlayerToString()
        {
            Player player = new Player("Phil", "Hale");

            Assert.NotNull(player);
            Assert.That(player.ToString(), Is.EqualTo("Phil Hale"));
        }
        public void CanGetPlayerShortName()
        {
            Player player = new Player("Phil", "Hale");

            Assert.NotNull(player);
            Assert.That(player.ShortName, Is.EqualTo("P Hale"));
        }
 public ClassWithTreeMatchingPropertiesCupTeamPlayer(Penalty penalty, int crappys, float felix, Cup cup, Team team, Player player)
 {
     this.Penalty = penalty;
     this.Crappys = crappys;
     this.felix = felix;
     this.Cup = cup;
     this.Team = team;
     this.Player = player;
 }
        public void CanCreatePlayer()
        {
            string firstname = "firstname";
            string surname = "surname";

            Player player = new Player(firstname, surname);

            Assert.IsNotNull(player);
            Assert.That(player.Forename, Is.EqualTo(firstname));
            Assert.That(player.Surname, Is.EqualTo(surname));
        }
        public void CanCreatePlayerWithTeam()
        {
            string firstname = "firstname";
            string surname = "surname";
            Team team = new Team("name", "longname");

            Player player = new Player(firstname, surname, team);

            Assert.IsNotNull(player);
            Assert.That(player.Forename, Is.EqualTo(firstname));
            Assert.That(player.Surname, Is.EqualTo(surname));
            Assert.That(player.Team, Is.EqualTo(team));
        }
        public PlayerFixture(TeamLeague teamLeague, Fixture fixture, Player player, int pointsScored, int fouls)
            : this()
        {
            Check.Require(teamLeague != null, "teamLeague cannot be null");
            Check.Require(fixture != null, "teamLeague cannot be null");
            Check.Require(player != null, "player cannot be null");
            Check.Require(pointsScored >= 0, "pointsScored must be greater than or equal to zero");
            Check.Require(fouls >= 0, "fouls must be greater than or equal to zero");

            this.TeamLeague = teamLeague;
            this.Fixture = fixture;
            this.Player = player;
            this.PointsScored = pointsScored;
            this.Fouls = fouls;
        }
        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 void CanCreatePlayerCareerStatsWithZeroGamesPlayed()
        {
            Player player = new Player("Phil", "Hale");
            int totalPoints = -2;
            int totalFouls = 2;
            int gamesPlayed = 0;
            int mvpAwards = 2;

            PlayerCareerStats stats = new PlayerCareerStats(player, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            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.GamesPlayed, Is.EqualTo(0));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
        public void CanCreatePlayerCareerStats()
        {
            Player player = new Player("Phil", "Hale");
            int totalPoints = 50;
            int totalFouls = 10;
            int gamesPlayed = 4;
            int mvpAwards = 1;

            PlayerCareerStats stats = new PlayerCareerStats(player, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            Assert.That(stats.TotalPoints, Is.EqualTo(totalPoints));
            Assert.That(stats.PointsPerGame, Is.EqualTo(12.5f));
            Assert.That(stats.TotalFouls, Is.EqualTo(totalFouls));
            Assert.That(stats.FoulsPerGame, Is.EqualTo(2.5f));
            Assert.That(stats.GamesPlayed, Is.EqualTo(gamesPlayed));
            Assert.That(stats.MvpAwards, Is.EqualTo(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 CanCreatePlayerWithAllFields()
        {
            string firstname = "firstname";
            string surname = "surname";
            Team team = new Team("name", "longname");
            DateTime dob = new DateTime(1981, 03, 01);
            int? heightInches = 4;
            int? heightFeet = 7;
            int calculatedAge = (int)((DateTime.Now.Date - dob).TotalHours / 24 / 365);

            Player player = new Player(firstname, surname, team);
            player.DOB = dob;
            player.HeightInches = heightInches;
            player.HeightFeet = heightFeet;

            Assert.IsNotNull(player);
            Assert.That(player.Forename, Is.EqualTo(firstname));
            Assert.That(player.Surname, Is.EqualTo(surname));
            Assert.That(player.Team, Is.EqualTo(team));
            Assert.That(player.DOB, Is.EqualTo(dob));
            Assert.That(player.Age, Is.EqualTo(calculatedAge));
            Assert.That(player.HeightFeet, Is.EqualTo(heightFeet));
            Assert.That(player.HeightInches, Is.EqualTo(heightInches));
        }
        //protected Fixture AddResult(int fixtureId, int homeScore, int awayScore)
        //{
        //    Fixture fixture = fixtureRepository.Get(fixtureId);
        //    //Console.WriteLine("Adding fixture - " + fixture.HomeTeamLeague.TeamName + " vs " + fixture.AwayTeamLeague.TeamName);
        //    fixture.HomeTeamScore = homeScore;
        //    fixture.AwayTeamScore = awayScore;
        //    fixture.IsPlayed = "Y";
        //    //fixtureRepository.SaveOrUpdate(fixture);
        //    //FlushSessionAndEvict(fixture);
        //    return fixture;
        //}
        //protected void AddResult(int fixtureId, int homeScore, int awayScore, int day, int month, int year, int hour, int minute)
        //{
        //    Fixture f = AddResult(fixtureId, homeScore, awayScore);
        //    f.ResultAddedDate = new DateTime(year, month, day, hour, minute, 0);
        //    fixtureRepository.SaveOrUpdate(f);
        //    FlushSessionAndEvict(f);
        //}
        //private void AddPenalty(League league, Team team, int points, string reason, Fixture fixture)
        //{
        //    Penalty penalty = new Penalty(league, team, points, reason, fixture);
        //    penaltyRepository.SaveOrUpdate(penalty);
        //    FlushSessionAndEvict(penalty);
        //}
        //private ContactType AddContactType(string desc)
        //{
        //    ContactType contactType = new ContactType(desc);
        //    contactType = contactRepository.SaveOrUpdateContactType(contactType);
        //    FlushSessionAndEvict(contactType);
        //    return contactType;
        //}
        //private Contact AddContact(string forename, string surname)
        //{
        //    Contact contact = new Contact(forename, surname);
        //    contact = contactRepository.SaveOrUpdateContact(contact);
        //    FlushSessionAndEvict(contact);
        //    return contact;
        //}
        //private ContactTypeRel AddContactTypeRel(Contact contact, ContactType contactType)
        //{
        //    ContactTypeRel rel = new ContactTypeRel(contact, contactType);
        //    rel = contactRepository.SaveOrUpdateContactTypeRel(rel);
        //    FlushSessionAndEvict(rel);
        //    return rel;
        //}
        //protected void DeleteAllContacts()
        //{
        //    contactRepository.DeleteContactTypeRelsForContact(1);
        //    contactRepository.DeleteContactTypeRelsForContact(2);
        //    contactRepository.DeleteContact(contactRepository.GetContact(1));
        //    contactRepository.DeleteContact(contactRepository.GetContact(2));
        //    contactRepository.DeleteContactType(contactRepository.GetContactType(1));
        //    contactRepository.DeleteContactType(contactRepository.GetContactType(2));
        //    contactRepository.DbContext.CommitChanges();
        //}
        // Just a dummy method so the NUnit doesn't hand out a big
        // fat fail for having no tests
        //[Test]
        //public void Test()
        //{
        //}
        protected Player AddPlayer(string forename, string surname, Team team)
        {
            Player player = new Player(forename, surname, team);

            //playerRepository.SaveOrUpdate(player);
            //FlushSessionAndEvict(player);
            return player;
        }
 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(Player @player)
 {
     if (ModelState.IsValid) {
                 playerService.Update(@player);
                 playerService.Commit();
                 SuccessMessage(FormMessages.SaveSuccess);
                 return RedirectToAction("Index");
         }
         return View(@player);
 }
 public PlayerViewModel()
 {
     Player = new Player();
 }
 public void MapToModel(Player player)
 {
     Player = player;
     if(player.Team != null)
         TeamId = player.Team.Id;
 }
 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 static PlayerSeasonStats CreatePlayerSeasonStats(int id, Player player, Season season)
        {
            PlayerSeasonStats p = new PlayerSeasonStats(player, season, 100, 20, 5, 1);
            EntityIdSetter.SetIdOf(p, id);

            return p;
        }
        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;
        }
        //protected Player SavePlayer(Player player)
        //{
        //    playerRepository.SaveOrUpdate(player);
        //    FlushSessionAndEvict(player);
        //    return player;
        //}
        private PlayerFixture AddPlayerFixture(TeamLeague teamLeague, Fixture fixture, Player player, int points, int fouls, bool isMvp)
        {
            PlayerFixture playerFixture = new PlayerFixture(teamLeague, fixture, player, points, fouls);

            if (isMvp)
                playerFixture.IsMvp = "Y";
            else
                playerFixture.IsMvp = "N";

            //statsRepository.SaveOrUpdatePlayerFixture(playerFixture);
            //FlushSessionAndEvict(playerFixture);
            return playerFixture;
        }
        public static Player CreatePlayer()
        {
            Player player = new Player("Phil", "Hale", CreateTeam());
            EntityIdSetter.SetIdOf(player, 1);

            return player;
        }