When a file is uploaded from the client, it can be found in this.Request.Files
, which is of type HttpFileCollectionBase
.
HttpFileCollectionBase
contains HttpPostedFileBase
entries.
The properties on these objects are read-only, so I was hoping I could setup some mocks. My mock request would return a mock HttpFileCollection
, and that collection would contain one mockHttpPostedFile
. The InputStream
property on that object would return a FileStream
object that I would instantiate using a real file in source control.
- Is this a good approach to uploading a file to an endpoint from an integration test?
- If it is a good approach, how can I mock this out
with
Moq
? - If this is not a good approach, can you suggest a better way?
Thanks!