예제 #1
0
            public void ReturnCorrectStatistic()
            {
                var expectation = TestData.PlayerStatistic;
                var statistic   = handler.GetStatistic(PlayerName);


                ((int)statistic["totalMatchesPlayed"]).Should().Be(expectation["totalMatchesPlayed"]);
                ((int)statistic["totalMatchesWon"]).Should().Be(expectation["totalMatchesWon"]);
                ((string)statistic["favoriteServer"]).Should().Be(expectation["favoriteServer"]);
                ((int)statistic["uniqueServers"]).Should().Be(expectation["uniqueServers"]);
                ((string)statistic["favoriteGameMode"]).Should().Be(expectation["favoriteGameMode"]);
                ((double)statistic["averageScoreboardPercent"]).Should()
                .BeApproximately((double)expectation["averageScoreboardPercent"], 0.0001);
                ((int)statistic["maximumMatchesPerDay"]).Should().Be(expectation["maximumMatchesPerDay"]);
                ((double)statistic["averageMatchesPerDay"]).Should()
                .BeApproximately((double)expectation["averageMatchesPerDay"], 0.0001);
                ((string)statistic["lastMatchPlayed"]).Should().Be(expectation["lastMatchPlayed"]);
                ((double)statistic["killToDeathRatio"]).Should()
                .BeApproximately((double)expectation["killToDeathRatio"], 0.0001);
            }
예제 #2
0
        private Task <Response> GetPlayerStatisticAsync(string playerName)
        {
            var task = new Task <Response>(() =>
            {
                Dictionary <string, dynamic> statistic;
                try
                {
                    statistic = playerStatisticHandler.GetStatistic(playerName);
                }
                catch (Exception e)
                {
                    logger.Error(e.Message);
                    return(HttpStatusCode.InternalServerError);
                }
                return(Response.AsJson(statistic));
            });

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