私はユニットテストを学ぼうとしており、ユニットテストを備えたこの非常に単純なクラスを持っています:
public class HomeController : Controller
{
public ActionResult Index()
{
return View(new HomeViewModel
{
LogoUrl = this.Url.Content("~/Images/product.png")
});
}
}
[TestMethod]
public void Index()
{
Assert.IsNotNull(new HomeController().Index() as ViewResult);
}
null 参照例外が発生しています。this.Url()ユニットテストなしで使用することに関連してHttpContextいると思います。
を使用している間に単体テストに合格するにはどうすればよいthis.Url()ですか? Moq を使用しても問題ありません。:)