public async Task PostAsync_TestRequestAndResponse() { var messageHandler = FakeResponseHandler.Create(HttpStatusCode.OK, endpoint, payload); var client = new RestfulClient(endpoint, messageHandler); var testObject = await client.PostAsync <TestObject>(endpoint, payload); Assert.IsNotNull(testObject); Assert.AreEqual(1, messageHandler.Requests.Count); var request = messageHandler.Requests.FirstOrDefault(); Assert.AreEqual(HttpMethod.Post, request.Method); Assert.AreEqual(new Uri(endpoint), request.RequestUri); Assert.IsNotNull(request.Content); }
protected async Task <TResponse> PostAsync <TRequest, TResponse>(TRequest request) where TRequest : APIRequestBodyBase <TRequest> where TResponse : APIResponseBodyBase <TResponse> { var result = await _handler.HandleAsync(() => { _restfulClient = _restfulClient ?? new RestfulClient(); return(_restfulClient.PostAsync(request.Url, request.ContentType, request.Headers, request.ToString(), request.SecurityProtocol, request.TimeOut, request.UseSecurity)); }); var response = APIResponseBodyBase <TResponse> .Deserialize(result); return(response); }