Exemplo n.º 1
0
        public void TestSortByValue()
        {
            var Data = new Data();
            ChampionshipStatistic statistic = new ChampionshipStatistic();

            statistic.CalculateStatistics();
            statistic.Sort(OrderType.Descending, SortType.Value);

            Assert.AreEqual("HAMILTON", ((ChampionshipDataElement)statistic.DriverStats[0]).CompetitorName);
        }
Exemplo n.º 2
0
        public void TestSortByIndex()
        {
            var Data = new Data();
            ChampionshipStatistic statistic = new ChampionshipStatistic();

            statistic.CalculateStatistics();
            statistic.Sort(OrderType.Ascending, SortType.Index);
            //The result here depends on the database: it should be the first car in the database.
            Assert.AreEqual("HAMILTON", ((ChampionshipDataElement)statistic.DriverStats[0]).CompetitorName);
        }
Exemplo n.º 3
0
        public static ChampionshipStatistic GetChampionships(Result[,] results, PointScoringSystem pointSystem, bool doublePoints)
        {
            ChampionshipStatistic statistic = new ChampionshipStatistic();
            statistic.PointSystem = pointSystem;
            statistic.DoublePoints = doublePoints;

            statistic.SetResults(results);
            statistic.CalculateStatistics();
            statistic.Sort(OrderType.Descending, SortType.Value);

            return statistic;
        }
Exemplo n.º 4
0
        public void TestPopulateChampionshipResults()
        {
            var Data = new Data();
            ChampionshipStatistic statistic = new ChampionshipStatistic();

            Result[,] results = new Result[Data.NumberOfDrivers, Data.NumberOfTracks];

            for (int i = 0; i < Data.NumberOfDrivers; i++)
            {
                //First round results:
                results[i, 0].position = (i + 1);
            }

            statistic.SetResults(results);
            statistic.CalculateStatistics();
            statistic.Sort(OrderType.Descending, SortType.Value);

            Assert.AreEqual(0, statistic.DriverStats[0].CompetitorIndex);
            Assert.AreEqual(25, ((ChampionshipDataElement)statistic.DriverStats[0]).Points);
            Assert.AreEqual(43, ((ChampionshipDataElement)statistic.TeamStats[0]).Points);
            Assert.AreEqual(1, ((ChampionshipDataElement)statistic.TeamStats[0]).NumberOfResults[0]);
        }