public async Task ThenDownloadFailed_IfReturnCodeIsntSuccessful() { // Arrange const string location = "http://ignored/path"; var retriever = new HttpPayloadRetriever(request => RespondWithStatusCode(HttpStatusCode.BadGateway)); // Act Stream actualPayload = await retriever.RetrievePayloadAsync(location); // Assert Assert.Equal(Stream.Null, actualPayload); }
public async Task ThenDownloadPayloadSucceeds() { // Arrange const string expectedPayload = "message data!", location = "http://ignored/path"; var retriever = new HttpPayloadRetriever(request => RespondWithContent(expectedPayload)); // Act using (var streamReader = new StreamReader(await retriever.RetrievePayloadAsync(location))) { // Assert string actualPayload = streamReader.ReadToEnd(); Assert.Equal(expectedPayload, actualPayload); } }