Assert.Equal(new() { Foo = 123 }, await lazyJson.LoadJsonAsync());
}
+
+ [Fact]
+ public async Task ReadAsString_Test()
+ {
+ using var responseContent = new StringContent("foo");
+ using var responseMessage = new HttpResponseMessage
+ {
+ StatusCode = HttpStatusCode.OK,
+ Content = responseContent,
+ };
+ using var response = new ApiResponse(responseMessage);
+
+ Assert.Equal("foo", await response.ReadAsString());
+ }
}
}
return new(this.responseMessage);
}
+
+ public async Task<string> ReadAsString()
+ {
+ using var content = this.responseMessage.Content;
+
+ return await content.ReadAsStringAsync()
+ .ConfigureAwait(false);
+ }
}
}