/// <inheritdoc/> public async Task <int> RenewChallengeAsync() { byte[] response = await SendRequestAsync(RequestHelpers.PrepareAS2_RENEW_CHALLENGE_Request()); if (response.Length > 0) { _currentChallenge = BitConverter.ToInt32(response.Skip(DataResolutionUtils.RESPONSE_CODE_INDEX).Take(sizeof(int)).ToArray(), 0); } return(_currentChallenge); }
public void GetPlayers_ShouldPopulateCorrectPlayers() { (byte[] playersPacket, object responseObject) = ResponseHelper.GetValidResponse(ResponseHelper.GetPlayers); var expectedObject = (List <Player>)responseObject; byte[] challengePacket = RequestHelpers.PrepareAS2_RENEW_CHALLENGE_Request(); // Both requests will be executed on AS2_PLAYER since thats how you refresh challenges. byte[][] requestPackets = new byte[][] { challengePacket, challengePacket }; // First response is the Challenge renewal response and the second byte[][] responsePackets = new byte[][] { challengePacket, playersPacket }; Mock <IUdpClient> udpClientMock = SetupReceiveResponse(responsePackets); SetupRequestCompare(requestPackets, udpClientMock); // Ayylmao it looks ugly as hell but we will improve it later on. using (var sq = new ServerQuery(udpClientMock.Object, _localIpEndpoint)) { Assert.Equal(JsonConvert.SerializeObject(expectedObject), JsonConvert.SerializeObject(sq.GetPlayers())); } }