public void GetServerInfo()
        {
            queryProcessor.AdvertiseServers.AddOrUpdate(firstServer.Endpoint, firstServer, (s, server) => firstServer);
            queryProcessor.AdvertiseServers.AddOrUpdate(secondServer.Endpoint, secondServer, (s, server) => secondServer);
            var info = jsonSerializer.Serialize(queryProcessor.AdvertiseServers.Values.ToArray());

            var result = queryProcessor.HandleGet(new Uri("http://localhost:8080/servers/info"));


            result.Status.Should().Be(HttpStatusCode.Accepted);
            result.Response.ShouldAllBeEquivalentTo(info.GetBytesInAscii());
        }
示例#2
0
        public void GetServersStats()
        {
            var endpoint = "12.12.12.12-1333";

            queryProcessor.AdvertiseServers.AddOrUpdate(firstServer.Endpoint, firstServer, (s, server) => firstServer);
            MultiAdd(endpoint, date1, 2, gameServer1);
            MultiAdd(endpoint, date1, 2, gameServer3);
            MultiAdd(endpoint, date2, 2, gameServer2);
            var answer = "{\"totalMatchesPlayed\":6," +
                         "\"maximumMatchesPerDay\":4," +
                         "\"averageMatchesPerDay\":3.0," +
                         "\"maximumPopulation\":4," +
                         "\"averagePopulation\":3.0," +
                         "\"top5GameModes\":[\"DM\",\"TDM\"]," +
                         "\"top5Maps\":[\"DM-HelloWorld\",\"DM\",\"DM-Hello\"]}";

            var result = queryProcessor
                         .HandleGet(new Uri("http://localhost:8080/servers/12.12.12.12-1333/stats"));

            result.Status.Should().Be(HttpStatusCode.Accepted);
            result.Response.ShouldAllBeEquivalentTo(answer.GetBytesInAscii());
        }