AspUnitRunner.Infrastructure.AspClient.PostRequest C# (CSharp) Method

PostRequest() public method

public PostRequest ( string address, NameValueCollection postValues ) : string
address string
postValues System.Collections.Specialized.NameValueCollection
return string
        public string PostRequest(string address, NameValueCollection postValues)
        {
            using (var webClient = _factory.Create()) {
                webClient.Credentials = Credentials;
                webClient.Encoding = Encoding ?? webClient.Encoding;
                var responseBytes = webClient.UploadValues(address, postValues);

                return _responseDecoder.DecodeResponse(webClient, responseBytes);
            }
        }

Usage Example

        public void PostRequest_with_credentials_should_set_web_client_credentials()
        {
            var credentials = new NetworkCredential("username", "password");

            var aspClient = new AspClient(_factory, _responseDecoder);
            aspClient.Credentials = credentials;
            var response = aspClient.PostRequest("", null);

            Assert.That(_webClient.Credentials, Is.EqualTo(credentials));
        }
All Usage Examples Of AspUnitRunner.Infrastructure.AspClient::PostRequest