public async Task ModuleUpdateMatchStatistic()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

            await Module.ProcessRequest(CreateRequest(
                                            JsonConvert.SerializeObject(Match1),
                                            $"/servers/{Match1.HostServer.Id}/matches/{Match1.EndTime.ToUtcFormat()}",
                                            HttpMethodEnum.Put));

            var response = await Module.ProcessRequest(CreateRequest(
                                                           JsonConvert.SerializeObject(Match2),
                                                           $"/servers/{Match1.HostServer.Id}/matches/{Match1.EndTime.ToUtcFormat()}",
                                                           HttpMethodEnum.Put));

            var combined = Match2;

            combined.HostServer = Match1.HostServer;
            combined.EndTime    = Match1.EndTime;

            response.Response.Should().Be(new HttpResponse(HttpStatusCode.OK));

            var result = await StatisticStorage.GetMatch(Match1.GetIndex());

            result.ShouldBeEquivalentTo(combined,
                                        options => options
                                        .Excluding(info => info.Id)
                                        .Excluding(info => info.Scoreboard));
        }
Beispiel #2
0
        public async Task PopularServers_AfterUpdate()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1);

            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1);
        }
        public async Task ModuleReturnsMatchInfo()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

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

            var response = await Module.ProcessRequest(CreateRequest("", $"/servers/{Match1.HostServer.Id}/matches/{Match1.EndTime.ToUtcFormat()}"));

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, Match1));
        }
Beispiel #4
0
        public async Task RecentMatches_MinimumCountValue_Is0()
        {
            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1.InitPlayers(Match1.EndTime));

            await WaitForTasks();

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

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, new object[] {}));
        }
        public async Task ModuleAddNewMatchStatistic()
        {
            await StatisticStorage.UpdateServer(Server1.GetIndex(), Server1);

            var response = await Module.ProcessRequest(CreateRequest(
                                                           JsonConvert.SerializeObject(Match1),
                                                           $"/servers/{Match1.HostServer.Id}/matches/{Match1.EndTime.ToUtcFormat()}",
                                                           HttpMethodEnum.Put));

            response.Response.Should().Be(new HttpResponse(HttpStatusCode.OK));

            var result = await StatisticStorage.GetMatch(Match1.GetIndex());

            result.Should().Be(Match1);
        }
Beispiel #6
0
        public async Task RecentMatches_AcceptNonCanonicalRoute()
        {
            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1.InitPlayers(Match1.EndTime));

            await WaitForTasks();

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

            var expected = new[]
            {
                new { server = Match1.HostServer.Id, timestamp = Match1.EndTime, results = Match1 }
            };

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, expected));
        }
Beispiel #7
0
        public async Task RecentMatches_ReturnAllMatches_IfLessThanCount()
        {
            await StatisticStorage.UpdateMatch(Match1.GetIndex(), Match1.InitPlayers(Match1.EndTime));

            await WaitForTasks();

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

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

            response.Response.Should().Be(new JsonHttpResponse(HttpStatusCode.OK, expected));
        }