Exemple #1
0
        public void TestTeamOfBestLeague()
        {
            LeagueLogic ll = new LeagueLogic(this.leagueRepo.Object);
            TeamLogic   tl = new TeamLogic(this.teamRepo.Object);

            StatLogic s = new StatLogic(tl, ll);

            List <League> leagues = new List <League>()
            {
                new League()
                {
                    LID = Guid.NewGuid().ToString(), Name = "Formula 1 (F1)", Rating = 8, Homology = true, RaceTypes = RaceType.circuit
                },
                new League()
                {
                    LID = Guid.NewGuid().ToString(), Name = "World Touring Car Championship (WTCC)", Rating = 7, Homology = false, RaceTypes = RaceType.circuit
                },
            };

            List <Team> teams = new List <Team>()
            {
                new Team {
                    TID = Guid.NewGuid().ToString(), TName = "Mercedes-AMG Petronas F1 Team", Created = 2010, Country = "Germany", Engine = ESuppliers.Mercedes, LID = leagues.ElementAt(0).LID
                },
                new Team {
                    TID = Guid.NewGuid().ToString(), TName = "Aston Martin Red Bull Racing", Created = 2005, Country = "Austria", Engine = ESuppliers.Honda, LID = leagues.ElementAt(0).LID
                },
                new Team {
                    TID = Guid.NewGuid().ToString(), TName = "Renault DP World F1 Team", Created = 1977, Country = "France", Engine = ESuppliers.Renault, LID = leagues.ElementAt(0).LID
                },
                new Team {
                    TID = Guid.NewGuid().ToString(), TName = "Zengő Motorsport Services KFT", Created = 1996, Country = "Hungary", Engine = ESuppliers.Seat, LID = leagues.ElementAt(1).LID
                },
            };

            List <Team> expected = new List <Team>();

            expected.Add(teams[1]);
            expected.Add(teams[0]);
            expected.Add(teams[2]);

            leagueRepo.Setup(x => x.Search()).Returns(leagues.AsQueryable);
            teamRepo.Setup(x => x.Search()).Returns(teams.AsQueryable);
            var result = s.TeamOfBestLeague();

            Assert.That(result, Is.EqualTo(expected));
        }
Exemple #2
0
        public IActionResult Statistics()
        {
            StatLogic statLogic = new StatLogic(leagueLogic, teamLogic, driverLogic);
            Stat      stat      = new Stat();

            //Oldest team drivers stat

            stat.OldestTeamDrivers = statLogic.OldestTeamDrivers();


            stat.MostDriverInTeam = statLogic.MostDriverInTeam();

            /*----------------------------------------------------------------------*/
            //Most popular League and its teams

            stat.TeamsOfBestLeague = statLogic.TeamOfBestLeague();

            /*----------------------------------------------------------------------*/
            //Most used engine type and count

            stat.MostUsedEngine = statLogic.MostUsedEngine();

            return(View(stat));
        }