samedi 6 août 2016

How do I get fake path for HttpContext.Current.Server.MapPath which is assigned to protected object inside method unit testing?

I am new to unit test, MSTest. I get NullReferenceException. How do I set HttpContext.Current.Server.MapPath for doing unit test in C#.

class Account
{
 protected string accfilepath;
 public Account(){
   accfilepath=HttpContext.Current.Server.MapPath("~/files/");
 }
}




class Test{
  [TestMethod]
  public void TestMethod()
  {
    Account ac= new Account();
  }
}

Aucun commentaire:

Enregistrer un commentaire