xunit test for IFormFile field in Asp.net Core
问题 I have an Asp.net Core method with below definition. [HttpPost] public IActionResult Upload(IFormFile file) { if (file == null || file.Length == 0) throw new Exception("file should not be null"); var originalFileName = ContentDispositionHeaderValue .Parse(file.ContentDisposition) .FileName .Trim('"'); file.SaveAs("your_file_full_address"); } I want to create XUnit Test for this function, how could I mock IFormFile ? Update: Controller: [HttpPost] public async Task<ActionResult> Post(IFormFile