コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public void GetStandingsForLeague_ThreeTeamTieResolvedByFixtureScoreDifference_Team_C_B_A()
        {
            List<TeamLeague> basicLeagueStands = new List<TeamLeague>();
            basicLeagueStands.Add(new TeamLeague() { Id = 1,  PointsLeague = 11, PointsScoredDifference = 50 });
            TeamLeague tiedTeamA = new TeamLeague() { Id = 2,  PointsLeague = 10, PointsScoredDifference = 100 };
            TeamLeague tiedTeamB = new TeamLeague() { Id = 3,  PointsLeague = 10, PointsScoredDifference = 100 };
            TeamLeague tiedTeamC = new TeamLeague() { Id = 4,  PointsLeague = 10, PointsScoredDifference = 100 };
            basicLeagueStands.Add(tiedTeamA);
            basicLeagueStands.Add(tiedTeamB);
            basicLeagueStands.Add(tiedTeamC);

            mockCompetitionRepository.GetBasicStandingsForLeague(1).ReturnsForAnyArgs(basicLeagueStands.AsQueryable());

            List<Fixture> tiedTeamFixtures = new List<Fixture>();

            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamA, AwayTeamLeague = tiedTeamB, HomeTeamScore = 40, AwayTeamScore = 20, IsPlayed = "Y" }); // A win
            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamA, AwayTeamLeague = tiedTeamC, HomeTeamScore = 40, AwayTeamScore = 20, IsPlayed = "Y" }); // A win
            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamB, AwayTeamLeague = tiedTeamA, HomeTeamScore = 41, AwayTeamScore = 20, IsPlayed = "Y" }); // B win
            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamB, AwayTeamLeague = tiedTeamC, HomeTeamScore = 40, AwayTeamScore = 20, IsPlayed = "Y" }); // B win
            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamC, AwayTeamLeague = tiedTeamA, HomeTeamScore = 42, AwayTeamScore = 20, IsPlayed = "Y" }); // C win
            tiedTeamFixtures.Add(new Fixture() { HomeTeamLeague = tiedTeamC, AwayTeamLeague = tiedTeamB, HomeTeamScore = 40, AwayTeamScore = 20, IsPlayed = "Y" }); // C win

            mockCompetitionRepository.GetFixturesForTeamLeagues(null).ReturnsForAnyArgs(tiedTeamFixtures);

            // C, B, A
            var standings = competitionService.GetStandingsForLeague(1);
            Assert.That(standings.Count, Is.EqualTo(4));
            Assert.That(standings[0].Id, Is.EqualTo(1));
            Assert.That(standings[1].Id, Is.EqualTo(tiedTeamC.Id));
            Assert.That(standings[2].Id, Is.EqualTo(tiedTeamB.Id));
            Assert.That(standings[3].Id, Is.EqualTo(tiedTeamA.Id));
        }
コード例 #4
0
        public bool IsAwayTeam(TeamLeague teamLeague)
        {
            if (teamLeague == null)
            {
                throw new ArgumentException("Parameter teamLeague cannot be null");
            }

            return(this.AwayTeamLeague.Id == teamLeague.Id);
        }
コード例 #5
0
 public TeamLeagueDto(TeamLeague tl)
 {
     this.TeamId       = tl.Team.Id;
     this.TeamName     = tl.TeamName;
     this.GamesPlayed  = tl.GamesPlayed.ToString();
     this.GamesWon     = tl.GamesWonTotal.ToString();
     this.GamesLost    = tl.GamesLostTotal.ToString();
     this.GamesPct     = tl.GamesPct.ToString("0.00");
     this.PointsLeague = tl.PointsLeague.ToString();
 }
コード例 #6
0
        public void GetGamesPlayed_TwoPlayedOneUnplayed_ReturnsTwo()
        {
            var teamLeagueA = new TeamLeague() { Id = 1 };
            var teamLeagueB = new TeamLeague() { Id = 2 };
            var teamLeagueC = new TeamLeague() { Id = 3 };
            var fixtures = new List<Fixture>();
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, true));
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true));
            fixtures.Add(GetFixture(teamLeagueC, teamLeagueB, true));
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true, false));

            Assert.That(teamLeagueA.GetGamesPlayed(fixtures), Is.EqualTo(2));
        }
コード例 #7
0
        public Fixture(TeamLeague homeTeamLeague, TeamLeague awayTeamLeague, DateTime fixtureDate, User lastUpdatedBy)
            : this()
        {
            // Check for required values
            Check.Require(homeTeamLeague != null, "homeTeamLeague must be provided");
            Check.Require(awayTeamLeague != null, "awayTeamLeague must be provided");
            Check.Require(lastUpdatedBy != null, "lastUpdatedBy must be provided");

            this.HomeTeamLeague = homeTeamLeague;
            this.AwayTeamLeague = awayTeamLeague;
            this.FixtureDate    = fixtureDate;
            this.LastUpdatedBy  = lastUpdatedBy;
        }
コード例 #8
0
        public Fixture(TeamLeague homeTeamLeague, TeamLeague awayTeamLeague, DateTime fixtureDate, User lastUpdatedBy)
            : this()
        {
            // Check for required values
            Check.Require(homeTeamLeague != null, "homeTeamLeague must be provided");
            Check.Require(awayTeamLeague != null, "awayTeamLeague must be provided");
            Check.Require(lastUpdatedBy != null, "lastUpdatedBy must be provided");

            this.HomeTeamLeague = homeTeamLeague;
            this.AwayTeamLeague = awayTeamLeague;
            this.FixtureDate    = fixtureDate;
            this.LastUpdatedBy  = lastUpdatedBy;
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        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;
        }
コード例 #11
0
        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;
        }
コード例 #12
0
        public ActionResult Create(TeamLeagueViewModel model)
        {
            if (ModelState.IsValid)
            {
                Team team = teamService.Get(model.TeamId);
                TeamLeague teamLeague = new TeamLeague(competitionService.GetLeague(model.LeagueId), team, team.TeamName, team.TeamNameLong);

                teamLeagueService.Insert(teamLeague);
                teamLeagueService.Commit();

                SuccessMessage(FormMessages.SaveSuccess);
                return RedirectToAction("Index");
            }

            PopulateStaticData(model);

            return View(model);
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        public TeamLeague ResetStats(TeamLeague tl)
        {
            tl.PointsLeague            = 0;
            tl.GamesPlayed             = 0;
            tl.GamesPct                = 0;
            tl.GamesWonTotal           = 0;
            tl.GamesWonHome            = 0;
            tl.GamesWonAway            = 0;
            tl.GamesLostTotal          = 0;
            tl.GamesLostHome           = 0;
            tl.GamesLostAway           = 0;
            tl.PointsScoredFor         = 0;
            tl.PointsScoredAgainst     = 0;
            tl.PointsScoredDifference  = 0;
            tl.Streak                  = null;
            tl.PointsAgainstPerGameAvg = 0;
            tl.PointsScoredPerGameAvg  = 0;
            tl.GamesForfeited          = 0;

            return tl;
        }
コード例 #15
0
 public void MapToModel(TeamLeague teamLeague)
 {
     TeamLeagueId = teamLeague.Id;
     LeagueId = teamLeague.League.Id;
     TeamId = teamLeague.Team.Id;
 }
コード例 #16
0
        public Fixture MapToFixture(Fixture fixture, TeamLeague homeTeamLeague, TeamLeague awayTeamLeague, Referee referee1, Referee referee2, User lastUpdatedBy, OneOffVenue oneOffVenue)
        {
            fixture.HomeTeamLeague = homeTeamLeague;
            fixture.AwayTeamLeague = awayTeamLeague;
            fixture.LastUpdatedBy  = lastUpdatedBy;
            fixture.LastUpdated    = DateTime.Now;

            // If you remove the few lines below accessing the referee objects you cannot reliably
            // set the properties to null. The assignment seems to be ignored.
            // By best guess is that the properties aren't lazy loaded until accessed so if you assign
            // a value to the property then read from it, the value gets loaded from the database. F****d up.
            fixture.Referee1.Touch();
            fixture.Referee2.Touch();

            fixture.Referee1 = referee1;
            fixture.Referee2 = referee2;

            fixture.OneOffVenue.Touch();
            fixture.OneOffVenue = oneOffVenue;

            return fixture;
        }
コード例 #17
0
 public void Teardown()
 {
     season         = null;
     homeTeam       = null;
     homeTeam       = null;
     league         = null;
     teamLeagueHome = null;
     teamLeagueAway = null;
     fixture        = null;
 }
コード例 #18
0
 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);
 }
コード例 #19
0
        // TODO This method really needs refactoring as it's difficult to unit test
        public void SaveMatchStats(bool hasPlayerStats, List<PlayerFixtureStats> playerStats, TeamLeague teamLeague, Fixture fixture)
        {
            // Deal appropriately with each player
            // Existing or non existing players that played - update or insert
            // Existing players that did not play - delete
            // Non existing players that did not play - ignore
            List<PlayerFixture> playerStatsToUpdate = new List<PlayerFixture>();
            PlayerFixture actionablePlayerFixture = null;
            foreach (var ps in playerStats)
            {
                if (ps.PlayerFixtureId > 0)
                    actionablePlayerFixture = this.statsReportingService.GetPlayerFixture(ps.PlayerFixtureId);
                else
                {
                    // Not need to add scores or fouls yet. That will be done by MapToPlayerFixture
                    // Not sure if the new Player setting Id thing will work
                    actionablePlayerFixture = new PlayerFixture(teamLeague, fixture, playerService.Get(ps.PlayerId), 0, 0);
                }

                if (ps.HasPlayed)
                {
                    matchResultRepository.InsertOrUpdatePlayerFixture(ps.MapToPlayerFixture(actionablePlayerFixture));
                    playerStatsToUpdate.Add(actionablePlayerFixture);
                }
                else if (!ps.HasPlayed && ps.PlayerFixtureId > 0)
                {
                    matchResultRepository.DeletePlayerFixture(actionablePlayerFixture);
                    // Awful hack alert. Because the PlayerFixture has been deleted the PlayerFixture.Player object will
                    // be null. But, we still need it, so the only solution I can currently think of is to get it again
                    playerStatsToUpdate.Add(new PlayerFixture(teamLeague, fixture, playerService.Get(ps.PlayerId), 0, 0));
                }
            }

            Commit();

            // Are all commits necessary?

            // Update player league stats
            UpdatePlayerLeagueStats(playerStatsToUpdate, teamLeague.League);
            Commit();

            // Update player season stats
            Season currentSeason = competitionService.GetCurrentSeason();
            UpdatePlayerSeasonStats(playerStatsToUpdate, currentSeason);
            Commit();

            if(fixture.IsCupFixture)
            {
                UpdatePlayerCupStats(playerStatsToUpdate, fixture.Cup, currentSeason);
                Commit();
            }

            // Update player career stats
            UpdatePlayerCareerStats(playerStatsToUpdate);
            Commit();

            // Update team stats
            UpdateTeamLeagueStats(teamLeague.Id);
            Commit();
        }
コード例 #20
0
        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));
        }
コード例 #21
0
 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;
 }
コード例 #22
0
        /// <summary>
        /// Returns a complete list of PlayerFixtureStats representing an entire team for 
        /// a fixture, regardless of whether the player has played in the fixture
        /// </summary>
        /// <param name="existingPlayerFixtures"></param>
        /// <param name="allPlayersInTeam"></param>
        /// <param name="teamLeague"></param>
        /// <param name="fixture"></param>
        /// <returns></returns>
        public List<PlayerFixtureStats> MapToPlayerFixtureStats(List<PlayerFixture> existingPlayerFixtures, 
            List<Player> allPlayersInTeam,
            TeamLeague teamLeague,
            Fixture fixture)
        {
            List<PlayerFixtureStats> playerFixturesScreen = new List<PlayerFixtureStats>();
            PlayerFixture existingPlayerFixture;

            foreach (Player player in allPlayersInTeam)
            {
                // Select PF record if exists
                existingPlayerFixture = existingPlayerFixtures.Where(x => x.Player.Id == player.Id).SingleOrDefault();

                // If a PF record exists, add it. If not, add a blank record
                if (existingPlayerFixture != null)
                    playerFixturesScreen.Add(new PlayerFixtureStats(existingPlayerFixture, true));
                else
                    playerFixturesScreen.Add(new PlayerFixtureStats(new PlayerFixture(teamLeague, fixture, player, 0, 0), false));

            }

            return playerFixturesScreen;
        }
コード例 #23
0
        public void GetLeaguePointsFromLosses_FourGamesTwoLossesHomeAndAway_ReturnsTwo()
        {
            var teamLeagueA = new TeamLeague() { Id = 1 };
            var teamLeagueB = new TeamLeague() { Id = 2 };
            var fixtures = new List<Fixture>();
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, false)); // A loss
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true)); // A loss
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, false)); // B loss

            Assert.That(teamLeagueA.GetLeaguePointsFromLosses(fixtures), Is.EqualTo(StandingsCalculations.LeaguePointsLoss * 2));
        }
コード例 #24
0
        public void GetLeaguePointsFromWins_FourGamesTwoWinsHomeAndAway_ReturnsSix()
        {
            var teamLeagueA = new TeamLeague() { Id = 1 };
            var teamLeagueB = new TeamLeague() { Id = 2 };
            var fixtures = new List<Fixture>();
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, true)); // A win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, false)); // A win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true)); // B win

            Assert.That(teamLeagueA.GetLeaguePointsFromWins(fixtures), Is.EqualTo(StandingsCalculations.LeaguePointsWin * 2));
        }
コード例 #25
0
        //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;
        }
コード例 #26
0
 public void UpdateTeamLeague(TeamLeague teamLeague)
 {
     teamLeagueRepository.Update(teamLeague);
 }
コード例 #27
0
        public bool IsHomeTeam(TeamLeague teamLeague)
        {
            if(teamLeague == null)
                throw new ArgumentException("Parameter teamLeague cannot be null");

            return this.HomeTeamLeague.Id == teamLeague.Id;
        }
コード例 #28
0
        public void GetPointsScoredFor_OneWinOneLoss_ReturnsForty()
        {
            var teamLeagueA = new TeamLeague() { Id = 1 };
            var teamLeagueB = new TeamLeague() { Id = 2 };
            var fixtures = new List<Fixture>();
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, true)); // A win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true)); // A loss

            Assert.That(teamLeagueA.GetPointsScoredFor(fixtures), Is.EqualTo(40));
        }
コード例 #29
0
        public void IsHomeTeam_PassHomeTeam_True()
        {
            TeamLeague homeTeamLeague = new TeamLeague() { Id = 1 };
            TeamLeague awayTeamLeague = new TeamLeague() { Id = 2 };
            Fixture f = new Fixture() { HomeTeamLeague = homeTeamLeague, AwayTeamLeague = awayTeamLeague};

            Assert.That(f.IsHomeTeam(homeTeamLeague), Is.True);
        }
コード例 #30
0
        //public void AddTeamLeaguePenalty(int teamLeagueId, int penaltyPoints)
        //{
        //    TeamLeague teamLeague = teamLeagueRepository.Get(teamLeagueId);
        //    teamLeague.PointsPenalty = penaltyPoints;
        //    //teamLeague = teamLeagueRepository.SaveOrUpdate(teamLeague);
        //    //FlushSessionAndEvict(teamLeague);
        //}
        private Fixture AddFixture(TeamLeague home, TeamLeague away, string fixtureDate, User lastUpdatedBy)
        {
            Fixture fixture = new Fixture(home, away, DateTime.Parse(fixtureDate), lastUpdatedBy);

            fixture.IsCupFixture = false;
            //fixture = fixtureRepository.SaveOrUpdate(fixture);
            //FlushSessionAndEvict(fixture);

            CurrentSeasonFixtures.Add(fixture);

            return fixture;
        }
コード例 #31
0
        public void HomeAndAwayWins_TwoHomeWinsOneAwayWin_ReturnsTwoHomeWinsAndOneAwayWin()
        {
            var teamLeagueA = new TeamLeague() { Id = 1 };
            var teamLeagueB = new TeamLeague() { Id = 2 };
            var teamLeagueC = new TeamLeague() { Id = 3 };
            var fixtures = new List<Fixture>();
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, true)); // A home win
            fixtures.Add(GetFixture(teamLeagueA, teamLeagueB, true)); // A home win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, false)); // A away win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueA, true)); // B win
            fixtures.Add(GetFixture(teamLeagueB, teamLeagueC, true));

            Assert.That(teamLeagueA.GetHomeWins(fixtures), Is.EqualTo(2));
            Assert.That(teamLeagueA.GetAwayWins(fixtures), Is.EqualTo(1));
            Assert.That(teamLeagueA.GetTotalWins(fixtures), Is.EqualTo(3));
        }
コード例 #32
0
        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;
        }
コード例 #33
0
        private Fixture GetFixture(TeamLeague homeTeamLeague, TeamLeague awayTeameLeague, bool isHomeWin, bool isPlayed = true)
        {
            var fixture = new Fixture() { HomeTeamLeague = homeTeamLeague, AwayTeamLeague = awayTeameLeague };

            fixture.IsPlayed = isPlayed ? "Y" : "N";

            if(isHomeWin)
            {
                fixture.HomeTeamScore = 30;
                fixture.AwayTeamScore = 10;
            }
            else
            {
                fixture.HomeTeamScore = 10;
                fixture.AwayTeamScore = 30;
            }

            return fixture;
        }