public void SetUp()
        {
            var allMatches    = TestData.Matches;
            var serverMatches = allMatches.Where(x => x.endpoint == endpoint).ToArray();

            database = A.Fake <IDatabaseAdapter>();
            A.CallTo(() => database.GetMatches(endpoint)).Returns(serverMatches);
            A.CallTo(() => database.GetMatches()).Returns(allMatches);
            handler = new ServerStatisticHandler(database);
        }
Beispiel #2
0
        public GetStatisticModule(
            ServerStatisticHandler serverStatisticHandler,
            PlayerStatisticHandler playerStatisticHandler,
            ReportsHandler reportsHandler
            )
        {
            this.serverStatisticHandler = serverStatisticHandler;
            this.playerStatisticHandler = playerStatisticHandler;
            this.reportsHandler         = reportsHandler;

            Get["/servers/{endpoint:url}/stats", true] = async(x, _) => await GetServerStatisticAsync(x.endpoint);

            Get["/players/{name}/stats", true] = async(x, _) => await GetPlayerStatisticAsync(x.name);

            Get["/reports/recent-matches/", true] = async(x, _) => await GetRecentMatchesReportAsync(Constants.DefaultCount);

            Get["/reports/recent-matches/{count:int}", true] = async(x, _) =>
            {
                var count = NormalizeCount(x.count);
                return(await GetRecentMatchesReportAsync(count));
            };

            Get["/reports/best-players/", true] = async(x, _) => await GetBestPlayersReportAsync(Constants.DefaultCount);

            Get["/reports/best-players/{count:int}", true] = async(x, _) =>
            {
                var count = NormalizeCount(x.count);
                return(await GetBestPlayersReportAsync(count));
            };

            Get["/reports/popular-servers/", true] = async(x, _) => await GetPopularServersReportAsync(Constants.DefaultCount);

            Get["/reports/popular-servers/{count:int}", true] = async(x, _) =>
            {
                var count = NormalizeCount(x.count);
                return(await GetPopularServersReportAsync(count));
            };
        }