I've asked a few questions about this, but haven't found the answer (or maybe understood what to do?).
We have an app that we are waiting to hear back from user testing. In the meantime, I was asked to create a TestProject and test out all aspects, which is something our group is trying to move towards. the app is written in C#, aspx.net.
I have most of it finished. But absolutely can't figure out how to test two aspects. I have methods that take (a)session vars, and (b)Request.Form data.
Everything I find about mocking seems to revolve around MVC architecture. The first question I asked (here) said I should "change the method to take an HttpRequestBase". I'm not supposed to change any code whatsoever (student placement).
How can I supply the form/session data to my unit test? I can't find anything specific to this.
Sucks to be new.
Thanks!
EDIT::
Sorry, I do have Moq, but am missing something....
Here is the session code. It's only in one place (one set of tests), where as I have instances of the Request.Form in about 7 or 8....
protected void Page_Load(object sender, EventArgs e)
{
//get the "Storage" location
String strStorage = Path.To.Default.Storage;
XDocument xmlDoc = XDocument.Load(Path.Combine(strStorage, "pending/") + Request.Form["thing"] + ".xml");
Session["Files"] = "";
foreach (XElement element in xmlDoc.Elements().Elements())
{
if (element.Name.ToString() != "File")
{
Session[element.Name.ToString()] = element.Value.ToString();
}
else
{
Session["Files"] = Session["Files"] + element.Value.ToString() + ";";
}
}
}