I am writing some unit test to check my end points of webservice. Fortunately I write some of the test cases for get/post request and it works fine except the one. I want to write the test case to check the file uploading method of webservice. The webservice endpoint on PostMan is :
The body of the request takes userID and fileUpload attribute.
I write the basic code for this but don't know how to pass the form data as request body in Nunit test case.
private HttpClient _client;
[Test]
public async Task UploadPDFfile()
{
var response = await _client.PostAsync("http://localhost:5000/documents/");
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
}
Can anyone please tell me how I can pass the form-data attribute in PostAsync method in Nunit testing C# to check the file upload functionality.