private T DeserializeResponse(HttpResponseMessage response) { using (var contentStream = response.Content.ReadAsStreamAsync().Result) using (var streamReader = new StreamReader(contentStream)) { return(PayUClientConverter.DeserializeResponse <T>(streamReader.ReadToEnd())); } }
private async Task <T> DeserializeResponseAsync(HttpResponseMessage response) { using (var contentStream = await response.Content.ReadAsStreamAsync()) using (var streamReader = new StreamReader(contentStream)) { return(PayUClientConverter.DeserializeResponse <T>(await streamReader.ReadToEndAsync())); } }
public void DeserializeResponse_CorrectStringResponse_CorrectDeserialize() { var result = PayUClientConverter.DeserializeResponse <PayUToken>(Json.ReadFromTestFiles("token.json")); Assert.Equal("fakeToken", result.AccessToken); Assert.Equal(999999, result.ExpireIn); Assert.Equal("type", result.TokenType); Assert.Equal("client_credentials", result.GrantType); }
public void DeserializeResponse_BadJsonStringResponseRetrivePayout_CorrectDeserialize() { var badJsonValue = @"{ ""payout"": { ""payoutId"": ""2DVZMPMFPN140219GUEEE000P01AFAFA"", ""amount"": ""1100""; ""status"": ""WAITING"" }, ""status"": { ""statusCode"": ""SUCCESS"" } }"; var result = PayUClientConverter.DeserializeResponse <RetrivePayoutResponse>(badJsonValue); Assert.Equal("SUCCESS", result.Status.StatusCode); Assert.Equal("2DVZMPMFPN140219GUEEE000P01AFAFA", result.RetrievePayout.PayoutId); Assert.Equal("1100", result.RetrievePayout.Amount); Assert.Equal("WAITING", result.RetrievePayout.Status); }