public async Task Post_RequestUrlAndAuthHeader_RequestMessageUriSet() { // Arrange const string requestUrl = "http://abc123.def/456"; const string formData = "ghi=789"; HttpRequestMessage message = null; var mockHttpMessageHandler = new Mock <HttpMessageHandler>(); mockHttpMessageHandler.Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task <HttpResponseMessage> .Factory.StartNew(() => new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{}") })) .Callback((HttpRequestMessage m, CancellationToken t) => message = m); var http = new RestHttpClient(new HttpClient(mockHttpMessageHandler.Object)); // Act await http.Post(requestUrl, formData); // Assert Assert.AreEqual(requestUrl, message.RequestUri.ToString()); }