public void ReturnCorrectStatistic()
        {
            var expectation = TestData.ServerStatistic;
            var statistic   = handler.GetStatistic(endpoint);

            ((int)statistic["totalMatchesPlayed"]).Should().Be(expectation["totalMatchesPlayed"]);
            ((int)statistic["maximumMatchesPerDay"]).Should().Be(expectation["maximumMatchesPerDay"]);
            ((double)statistic["averageMatchesPerDay"]).Should().BeApproximately((double)expectation["averageMatchesPerDay"], 0.00001);
            ((int)statistic["maximumPopulation"]).Should().Be(expectation["maximumPopulation"]);
            ((double)statistic["averagePopulation"]).Should().BeApproximately((double)expectation["averagePopulation"], 0.0001);
            ((IList <string>)statistic["top5GameModes"]).Should().ContainInOrder((IList <string>)expectation["top5GameModes"]);

            ((IList <string>)statistic["top5Maps"]).Should().StartWith(expectation["top5Maps"][0])
            .And.BeEquivalentTo(expectation["top5Maps"]);
        }
Пример #2
0
        private Task <Response> GetServerStatisticAsync(string endpoint)
        {
            var task = new Task <Response>(() =>
            {
                Dictionary <string, dynamic> statistic;
                try
                {
                    statistic = serverStatisticHandler.GetStatistic(endpoint);
                }
                catch (Exception e)
                {
                    logger.Error(e.Message);
                    return(HttpStatusCode.InternalServerError);
                }
                return(Response.AsJson(statistic));
            });

            task.Start();
            return(task);
        }