public void SendAsync_RequestNull() { var acceptedMedia = new Mock <IAcceptedMediaSource>(MockBehavior.Strict).Object; var next = new Mock <IHttpService>(MockBehavior.Strict).Object; var uut = new HttpServiceAddAcceptHeader(acceptedMedia, next); Assert.ThrowsAsync <ArgumentNullException>( async() => await uut.SendAsync(null) ); }
public async Task SendAsync() { var media = new MediaTypeWithQualityHeaderValue("application/vnd.lrp.v1+json"); var acceptedMedia = new Mock <IAcceptedMediaSource>(MockBehavior.Strict); var request = new HttpRequestMessage(); var expectedResponse = new HttpResponseMessage(); var next = new Mock <IHttpService>(MockBehavior.Strict); var sequence = new MockSequence(); acceptedMedia.InSequence(sequence).Setup(a => a.Get()).Returns(media); next.InSequence(sequence).Setup(n => n.SendAsync(request)).ReturnsAsync(expectedResponse); var uut = new HttpServiceAddAcceptHeader(acceptedMedia.Object, next.Object); var actualResponse = await uut.SendAsync(request); Assert.AreEqual(expectedResponse, actualResponse); Assert.AreEqual(media.MediaType, request.Headers.Accept.ToString()); }