Mock HttpPostedFile in Unit Test

Viewed 2346
public async Task<HttpResponseMessage> UpdateUserProfile(HttpPostedFile postedFile)
{ 
  //update operations
}

I have a method UpdateUserProfile where I am updating the image of a person using HttpPostedFile. It is working fine from Postman/Swagger. Now am writing UnitTestCases for the same. I have the below code

public void UpdateUserProfile_WithValidData()
{
   HttpPostedFile httpPostedFile;
   //httpPostedFile =??

  var returnObject =  UpdateUserProfile( httpPostedFile );

  //Assert code here
}

Now I have to give the image file to HttpPostedFile object from code manually which I am trying to do but couldn't. Please suggest me how to proceed further to mock image in the unit test.

1 Answers
Related