I have following asp.net Page Contact
and having TestHandlerDemoClass
which is having one method I want to write a unit test case for that method but when I tried it using MSTest project
it throws exception like
Request not available in this context
public partial class Contact : Page
{
}
public class TestHandlerDemoClass
{
public void MyTestMethod(Page mypage)
{
string id= mypage.Request["EntityId"]
//here I'm not getting Request inside mypage
My Test Project code -
[TestClass]
public class UnitTest1
{
[TestMethod]
public void NullCheck()
{
try
{
Contact contactPage = new Contact();
TestHandlerDemoClass mydemo = new TestHandlerDemoClass();
mydemo.MyTestMethod(contactPage);
}
catch (Exception ex)
{
Assert.AreEqual(ex.Message, "Id not found");
}
}
}
here in above ex I got message like {"Request is not available in this context"}
I 'm just trying to write unit test cases for method `
public void MyTestMethod(Page mypage)
which takes Page mypage
as parameter.
how to do it?