S
Seth
I have been trying to create a mock httpcontext for the
purpose of unit testing. I have a class, Customer, that
uses cookies. I have set it up to be able to take a
httpcontext as a parameter in an overloaded constructor.
I have seen a few references to people that have created
mock httpcontexts but I can not seem to get it to work.
This is what I have right now, it is the result of
working backwards from httpcontext and trial and error.
It compiles fine but the swrq is not set to an instance
of an object at runtime.
SimpleWorkerRequest swrq;
TextWriter output = new StringWriter();
using(TextWriter streamWriter = new StreamWriter
("InvalidPathChars.txt"))
swrq = new System.Web.Hosting.SimpleWorkerRequest
( "page", "query", output );
return new HttpContext( swrq );
Does anyone have any links to information about this?
purpose of unit testing. I have a class, Customer, that
uses cookies. I have set it up to be able to take a
httpcontext as a parameter in an overloaded constructor.
I have seen a few references to people that have created
mock httpcontexts but I can not seem to get it to work.
This is what I have right now, it is the result of
working backwards from httpcontext and trial and error.
It compiles fine but the swrq is not set to an instance
of an object at runtime.
SimpleWorkerRequest swrq;
TextWriter output = new StringWriter();
using(TextWriter streamWriter = new StreamWriter
("InvalidPathChars.txt"))
swrq = new System.Web.Hosting.SimpleWorkerRequest
( "page", "query", output );
return new HttpContext( swrq );
Does anyone have any links to information about this?