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 void GetForfeitedGames_OneHomeForfeitOneAwayForfeit_ReturnsTwo()
        {
            List<Fixture> fixtures = new List<Fixture>();
            Team forfeitingTeam = new Team() { Id = 11 };
            TeamLeague forfeitingTeamLeague =  new TeamLeague() { Id = 1, Team = forfeitingTeam };
            TeamLeague winningTeamLeague =  new TeamLeague() { Id = 2, Team = new Team() { Id = 12 } };
            fixtures.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 1,
                HomeTeamLeague = forfeitingTeamLeague,
                AwayTeamLeague = winningTeamLeague,
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam
            });

            fixtures.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 1,
                HomeTeamLeague = winningTeamLeague,
                AwayTeamLeague = forfeitingTeamLeague,
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam
            });

            Assert.That(forfeitingTeamLeague.GetGamesPlayed(fixtures), Is.EqualTo(2));
        }
        public LeagueWinner(League league, Team team)
            : this()
        {
            Check.Require(league != null, "league must be provided");
            Check.Require(team != null, "team must be provided");

            this.League = league;
            this.Team = team;
        }
 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 CanCreateTeamWithValidWebSite()
        {
            String url = "http://www.bbc.co.uk";

            Team team = new Team("Name", "Long name");
            team.WebSiteUrl = url;

            Assert.IsNotNull(team);
            Assert.That(url, Is.EqualTo(team.WebSiteUrl));
        }
        public void CanCreateTeam()
        {
            string teamName = "Velocity";
            string teamNameLong = "Nunthorpe Velocity";

            Team season = new Team(teamName, teamNameLong);

            Assert.IsNotNull(season);
            Assert.That(season.TeamName, Is.EqualTo(teamName));
            Assert.That(season.TeamNameLong, Is.EqualTo(teamNameLong));
        }
        public Player(string forename, string surname, Team team)
            : this()
        {
            Check.Require(!string.IsNullOrEmpty(forename) && forename.Trim() != string.Empty, "forename must be provided");
            Check.Require(!string.IsNullOrEmpty(surname) && surname.Trim() != string.Empty, "surname must be provided");
            Check.Require(team != null, "team must be provided");

            Forename = forename;
            Surname = surname;
            Team = team;
        }
        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 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 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 Penalty(League league, Team team, int points, string reason)
            : this()
        {
            Check.Require(league != null, "league must be provided");
            Check.Require(team != null, "team must be provided");
            Check.Require(points > 0, "points must be greater than zero");
            Check.Require(!string.IsNullOrEmpty(reason) && reason.Trim() != string.Empty,
                "reason must be provided");

            this.League = league;
            this.Team = team;
            this.Points = points;
            this.Reason = reason;
        }
        public static Fixture CreateFixture(int id)
        {
            Season season = CreateSeason();
            EntityIdSetter.SetIdOf(season, 1);
            Team team = new Team("teamName", "teamNameLong");
            League league = new League(season, "league desc", 1, 1);
            EntityIdSetter.SetIdOf(league, 1);
            TeamLeague teamLeague = new TeamLeague(league, team, "teamName", "teamNameLong");

            Fixture fixture = new Fixture(teamLeague, teamLeague, DateTime.Today, CreateUser());
            fixture.IsCupFixture = false;
            EntityIdSetter.SetIdOf(fixture, id);
            return fixture;
        }
        public TeamLeague(League league, Team team, string teamName, string teamNameLong)
            : this()
        {
            Check.Require(league != null, "league must be provided");
            Check.Require(team != null, "team must be provided");
            Check.Require(!string.IsNullOrEmpty(teamName) && teamName.Trim() != string.Empty,
                            "teamName must be provided");
            Check.Require(!string.IsNullOrEmpty(teamNameLong) && teamNameLong.Trim() != string.Empty,
                            "teamName must be provided");

            this.League = league;
            this.Team = team;
            this.TeamName = teamName;
            this.TeamNameLong = teamNameLong;
        }
        public void GetHomeLosses_HomeForfeitExcludeForfeits_ReturnsZero()
        {
            Team forfeitingTeam = new Team() { Id = 11 };
            TeamLeague teamLeague = new TeamLeague() { Id = 1, Team = forfeitingTeam };
            List<Fixture> fixtures = new List<Fixture>();

            fixtures.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 1,
                HomeTeamLeague = new TeamLeague() { Id = 2, Team = new Team() { Id = 12 }},
                AwayTeamLeague = teamLeague,
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam
            });

            Assert.That(teamLeague.GetHomeLosses(fixtures, false), Is.EqualTo(0));
        }
        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 UpdateTeamLeagueStats_OneHomeGameOneAwayOtherTeamForfeitBothGames_Success()
        {
            List<Fixture> fixturesForOneHomeOneAwayBothForfeit = new List<Fixture>();
            Team forfeitingTeam1 = new Team() { Id = 12 };
            Team forfeitingTeam2 = new Team() { Id = 13 };
            fixturesForOneHomeOneAwayBothForfeit.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 1,
                HomeTeamLeague = new TeamLeague() { Id = 1, Team = new Team() { Id = 11 } },
                AwayTeamLeague = new TeamLeague() { Id = 2, Team = forfeitingTeam1 },
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam1
            });
            fixturesForOneHomeOneAwayBothForfeit.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 2,
                HomeTeamLeague = new TeamLeague() { Id = 2, Team = forfeitingTeam2 },
                AwayTeamLeague = new TeamLeague() { Id = 1, Team = new Team() { Id = 11 } },
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam2
            });

            this.mockCompetitionService.GetTeamLeague(1).Returns(this.GetValidTeamLeague(1, 0));
            mockFixtureService.GetPlayedFixturesForTeamInReverseDateOrder(1).Returns(fixturesForOneHomeOneAwayBothForfeit);

            TeamLeague returnValue = matchResultService.UpdateTeamLeagueStats(1);

            Assert.                                                                         IsNotNull(returnValue);
            Assert.That(returnValue.GamesPlayed,                                            Is.EqualTo(2), "games played incorrect");
            Assert.That(returnValue.PointsLeague,                                           Is.EqualTo(6), "pts league incorrect");
            Assert.That(returnValue.GamesWonTotal,                                          Is.EqualTo(2), "games won incorrect");
            Assert.That(returnValue.GamesWonHome,                                           Is.EqualTo(1), "games won home incorrect");
            Assert.That(returnValue.GamesWonAway,                                           Is.EqualTo(1), "games won away incorrect");
            Assert.That(returnValue.GamesLostTotal,                                         Is.EqualTo(0), "games lost incorrect");
            Assert.That(returnValue.GamesLostHome,                                          Is.EqualTo(0), "games lost home incorrect");
            Assert.That(returnValue.GamesLostAway,                                          Is.EqualTo(0), "games lost away incorrect");
            Assert.That(returnValue.GamesPct,                                               Is.EqualTo(1.00), "games pct incorrect");
            Assert.That(returnValue.PointsScoredFor,                                        Is.EqualTo(40), "pts for incorrect");
            Assert.That(returnValue.PointsScoredAgainst,                                    Is.EqualTo(0), "pts against incorrect");
            Assert.That(returnValue.PointsScoredDifference,                                 Is.EqualTo(40), "pts diff incorrect");
            Assert.That(returnValue.Streak,                                                 Is.EqualTo("W2"), "streak incorrect");
            Assert.That((float)Math.Round(returnValue.PointsScoredPerGameAvg, 2),           Is.EqualTo(20f), "pts scored pg incorrect");
            Assert.That((float)Math.Round(returnValue.PointsAgainstPerGameAvg, 2),          Is.EqualTo(0f), "pts against pg incorrect");
            Assert.That((float)Math.Round(returnValue.PointsScoredPerGameAvgDifference, 2), Is.EqualTo(20f), "pts scored pg diff incorrect");
            Assert.That(returnValue.PointsPenalty,                                          Is.EqualTo(0));
            Assert.That(returnValue.GamesForfeited,                                         Is.EqualTo(0));

            this.mockMatchResultRepository.ReceivedWithAnyArgs().UpdateTeamLeague(null);
        }
 public LeagueWinnerTests()
 {
     season = new Season(2008, 2009);
     league = new League(season, "My League", 1, 1);
     team = new Team("Velocity", "Nunthorpe Velocity");
 }
 public ActionResult Edit(Team @team)
 {
     if (ModelState.IsValid) {
                 teamService.Update(@team);
                 teamService.Commit();
                 SuccessMessage(FormMessages.SaveSuccess);
                 return RedirectToAction("Index");
         }
         return View(@team);
 }
 public TeamNameDto(Team team)
 {
     this.TeamId   = team.Id;
     this.TeamName = team.TeamName;
 }
 public MyTeamViewModel()
 {
     Team = new Team();
     Team.GameDay = new DayOfWeek();
 }
Example #22
0
 public Penalty(League league, Team team, int points, string reason, Fixture fixture)
     : this(league, team, points, reason)
 {
     this.Fixture = fixture;
 }
 public Penalty(League league, Team team, int points, string reason, Fixture fixture)
     : this(league, team, points, reason)
 {
     this.Fixture = fixture;
 }
 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;
 }
        public void GetHomeWins_AwayForfeit_ReturnsOne()
        {
            TeamLeague teamLeague = new TeamLeague() { Id = 1, Team = new Team() { Id = 12 } };
            List<Fixture> fixtures = new List<Fixture>();
            Team forfeitingTeam = new Team() { Id = 11 };
            fixtures.Add(new Fixture()
            {
                IsPlayed = "Y",
                IsCupFixture = false,
                Id = 1,
                HomeTeamLeague = teamLeague,
                AwayTeamLeague = new TeamLeague() { Id = 2, Team = forfeitingTeam},
                IsForfeit = true,
                ForfeitingTeam = forfeitingTeam
            });

            Assert.That(teamLeague.GetHomeWins(fixtures), Is.EqualTo(1));
        }
 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 CupWinnerTests()
 {
     season = new Season(2008, 2009);
     cup = new Cup("My Cup");
     team = new Team("Velocity", "Nunthorpe Velocity");
 }
        private Team AddTeam(string teamName, string teamNameLong)
        {
            Team team = new Team(teamName, teamNameLong);

            //team = teamRepository.SaveOrUpdate(team);
            //FlushSessionAndEvict(team);

            return team;
        }
        private TeamLeague AddTeamLeague(Team team, League league)
        {
            TeamLeague teamLeague = new TeamLeague(league, team, team.TeamName, team.TeamNameLong);

            //teamLeague = teamLeagueRepository.SaveOrUpdate(teamLeague);
            //FlushSessionAndEvict(teamLeague);

            return teamLeague;
        }
 public void Teardown()
 {
     season         = null;
     homeTeam       = null;
     homeTeam       = null;
     league         = null;
     teamLeagueHome = null;
     teamLeagueAway = null;
     fixture        = null;
 }