Any way to create HttpPosted File?

  • Thread starter Thread starter Shimon Sim
  • Start date Start date
S

Shimon Sim

I am writing a unit test for the class that will take a HttpPostedFile in of
it methods as a parameter. I need to pass this parameter to the method in
the test but I don't see any way to create this file using C#.
I understand that from security point of view it makes sense but I got to
write this test unless it's impossible.
Thanks,
Shimon.
 
Shimon said:
I am writing a unit test for the class that will take a
HttpPostedFile in of it methods as a parameter. I need to pass this
parameter to the method in the test but I don't see any way to create
this file using C#.
I understand that from security point of view it makes sense but I
got to write this test unless it's impossible.

I suggest changing the method so it doesn't accept a HttpPostedFile object,
but a Stream instead. This decouples your logic from ASP.NET specific
objects and makes it much easier to test -- not to mention enhanced
resuability.

Cheers,
 
Back
Top