예제 #1
0
        public async Task RecentMatches_ReturnNotMoreThanCountEntries()
        {
            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1.InitPlayers(Match1.EndTime));

            await StatisticStorage.UpdateMatch(Match2.GetIndex(), Match2.InitPlayers(Match2.EndTime));

            await WaitForTasks();

            var response = await Module.ProcessRequest(CreateRequest("", "/reports/recent-matches/1"));

            var expected = new[]
            {
                new { server = Match1.HostServer.Id, timestamp = Match1.EndTime, results = Match1 },
                new { server = Match2.HostServer.Id, timestamp = Match2.EndTime, results = Match2 },
            }.OrderByDescending(m => m.timestamp).Take(1).ToArray();

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, expected));
        }
예제 #2
0
        public async Task PopularServers_ReturnMostPopularServer()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

            await StatisticStorage.UpdateServer(Server2.GetIndex(), Server2);

            await StatisticStorage.UpdateMatch(Match2.GetIndex(), Match2.InitPlayers(Match2.EndTime));

            await WaitForTasks();

            var response = await Module.ProcessRequest(CreateRequest("", "/reports/popular-servers/1"));

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, new[]
            {
                new
                {
                    endpoint             = Server2.Id,
                    name                 = Server2.Name,
                    averageMatchesPerDay = 1.0,
                }
            }));
        }