public async Task AsStream_OfModel(string content) { // arrange IResponse response = this.ConstructResponse(new Model <string>(content)); string actual; // act using (Stream stream = await response.AsStream().VerifyTaskResultAsync()) using (StreamReader reader = new StreamReader(stream)) actual = reader.ReadToEnd(); // assert Assert.That(actual, Is.EqualTo(string.Format("{{\"Value\":\"{0}\"}}", content))); }
public void AsStream(string content) { // arrange IResponse response = this.ConstructResponse(content); string actual; // act using (Stream stream = response.AsStream().VerifyTaskResult()) using (StreamReader reader = new StreamReader(stream)) actual = reader.ReadToEnd(); // assert Assert.That(actual, Is.EqualTo(String.Format("\"{0}\"", content))); }
public async Task AsStream(string content) { // arrange IResponse response = this.ConstructResponse(content); string actual; // act using (Stream stream = await response.AsStream().VerifyTaskResultAsync()) using (StreamReader reader = new StreamReader(stream)) actual = reader.ReadToEnd(); // assert Assert.That(actual, Is.EqualTo($"\"{content}\"")); }
/// <summary>Asynchronously retrieve the response body as a <see cref="Stream"/>.</summary> /// <returns>Returns the response body, or <c>null</c> if the response has no body.</returns> /// <exception cref="ApiException">An error occurred processing the response.</exception> public async Task <Stream> AsStream() { IResponse response = await this.AsResponse().ConfigureAwait(false); return(await response.AsStream().ConfigureAwait(false)); }