Is it possible to Serialize or Create a System.Web.UI.Page item?
I have a method that takes a System.Web.UI.Page as an input and returns some application specific details (what "type" of page it is, if certain items are in the query string, etc...). To run a unit test on this I was trying to create a System.Web.UI.Page item (in the code I am able to just send this.Page).
First Attempt: Serialization - I tried to serialize the page to a file and then deserialize to create the standard test page. Received many errors about not being able to serialize a Page. Is there anyway to write that object to a file?
Second Attempt: new Page() - I tried to just create the page and set the items I was interested in, but all the items I'm interested in appear to be read-only (no setter). Is there some way to create a System.Web.UI.Page programatically?
Why not mock out the Page class using a mocking framework? This is exactly the kind of scenario mocking is used for. I personally like Moq.