Esempio n. 1
0
        /// <inheritdoc/>
        public async Task <ServerInfo> GetServerInfoAsync()
        {
            var sInfo = new ServerInfo
            {
                Ping = new Ping().Send(_remoteIpEndpoint.Address).RoundtripTime
            };

            byte[] response = await SendRequestAsync(RequestHelpers.PrepareAS2_INFO_Request());

            if (response.Length > 0)
            {
                DataResolutionUtils.ExtractData(sInfo, response, nameof(sInfo.EDF), true);
            }

            return(sInfo);
        }
Esempio n. 2
0
        public void GetServerInfo_ShouldPopulateCorrectServerInfo()
        {
            (byte[] responsePacket, object responseObject) = ResponseHelper.GetValidResponse(ResponseHelper.ServerInfo);
            var expectedObject = (ServerInfo)responseObject;

            byte[][] requestPackets  = new byte[][] { RequestHelpers.PrepareAS2_INFO_Request() };
            byte[][] responsePackets = new byte[][] { responsePacket };

            Mock <IUdpClient> udpClientMock = SetupReceiveResponse(responsePackets);

            SetupRequestCompare(requestPackets, udpClientMock);

            using (var sq = new ServerQuery(udpClientMock.Object, _localIpEndpoint))
            {
                Assert.Equal(JsonConvert.SerializeObject(expectedObject), JsonConvert.SerializeObject(sq.GetServerInfo()));
            }
        }