public void VerifyXmlDataServiceAsync(string scriptPath, XdsRequestDocument requestDocument, bool? compress, bool? security) { var serializer = GetSerializer(compress, security); var requestBytes = serializer.Serialize(requestDocument.ConvertToBytes()); var webClient = new WebClient(); var uploadTask = webClient.UploadDataTask(new Uri(scriptPath), "POST", requestBytes); uploadTask.Wait(); var responseBytes = uploadTask.Result; var xdsResponse = ((byte[])serializer.Deserialize(responseBytes)).ConvertToXdsResponseDocument(); Assert.IsNotNull(xdsResponse); Assert.IsFalse(xdsResponse.HasError); }
/// <summary>Uploads data to the specified resource, asynchronously.</summary> /// <param name="webClient">The WebClient.</param> /// <param name="address">The URI to which the data should be uploaded.</param> /// <param name="method">The HTTP method that should be used to upload the data.</param> /// <param name="data">The data to upload.</param> /// <returns>A Task containing the data in the response from the upload.</returns> public static Task <byte[]> UploadDataTask(this WebClient webClient, string address, string method, byte[] data) { return(webClient.UploadDataTask(new Uri(address), method, data)); }