public async Task <ActionResult> GetStatus([FromRoute, ModelBinder] ApiModels.ServerInfoRequest request)
        {
            var serverRequest = _serverInfoRequestMapper.Map(request, GameType.Quake3);
            var serverDetails = await _q3aManager.GetStatus(serverRequest);

            if (serverDetails.Status != ServerStatus.Offline)
            {
                return(Ok(serverDetails));
            }
            else
            {
                return(NotFound());
            }
        }
示例#2
0
        public async Task SetUp()
        {
            _serverRequest = new ServerRequest
            {
                IpAddress = "192.168.200.201",
                Port      = 27960,
                GameType  = GameType.Quake3
            };

            _serverResponse = new ServerResponse
            {
                Data    = "????statusResponse\n\\capturelimit\\8\\g_maxGameClients\\0\\bot_minplayers\\5\\sv_floodProtect\\1\\sv_maxPing\\0\\sv_minPing\\0\\sv_dlRate\\100\\sv_maxRate\\0\\sv_minRate\\0\\sv_maxclients\\12\\sv_hostname\\test server name\\g_gametype\\0\\timelimit\\15\\fraglimit\\20\\dmflags\\0\\version\\ioq3 1.36_GIT_f2c61c14-2020-02-11 linux-x86_64 Apr 11 2020\\com_gamename\\Quake3Arena\\com_protocol\\71\\mapname\\Q3DM8\\sv_privateClients\\0\\sv_allowDownload\\0\\gamename\\baseq3\\g_needpass\\0\n15 3 \" ^ 5AbyssMisty\"\n13 0 \"Doom\"\n6 0 \"Angel\"\n10 4 \"^1cherry\"\n6 0 \"Phobos\"\n",
                Success = true,
                Error   = string.Empty
            };

            _pingResponse = new PingResponse
            {
                Milliseconds = 50,
                Success      = true
            };

            _mockQuake3GameClient     = new Mock <IQuake3GameClient>();
            _mockPingClient           = new Mock <IPingClient>();
            _mockStatusResponseMapper = new Mock <IStatusResponseMapper>();

            _mockPingClient.Setup(c => c.Ping(_serverRequest.IpAddress)).ReturnsAsync(_pingResponse);
            _mockQuake3GameClient.Setup(c => c.GetStatus(_serverRequest.IpAddress, _serverRequest.Port)).ReturnsAsync(_serverResponse);
            _mockStatusResponseMapper.Setup(c => c.Map(_serverResponse.Data)).Returns(new ServerStatusDetails {
                Name = "test server name"
            });

            _manager = new Quake3Manager(_mockQuake3GameClient.Object, _mockPingClient.Object, _mockStatusResponseMapper.Object);

            _result = await _manager.GetStatus(_serverRequest);
        }