I have a service that is using an upload service that we wrote. The upload service gets the files from Request.Files and then adds them to VirtualFiles. I am not certain how to mock this when testing my other service. Any advice or guidelines would be helpful. Here is what I have so far:
IHttpFile httpFile = new HttpFile { ContentType = "application/x-msaccess", FileName = "C:\\Tutorial Data\\CompanyC.mdb", ContentLength = };
MockHttpRequest mockRequestContext = new MockHttpRequest {Files = new IHttpFile[] { httpFile }};
for (int i = 0; i < mockRequestContext.Files.Length; i++)
{
IHttpFile file = mockRequestContext.Files[i];
string fileId = Guid.NewGuid().ToString();
string filename = UploadUtils.GetFileName(sessionId, fileId);
uploadFilesService.VirtualFiles.WriteFile(filename, file.InputStream);
}
However, I get a null exception error in the last line “Value cannot be null” parameter input.
Thanks for your time.