title: ASP.NET MVC Simple Controller Unit Test
body: <p>I'm trying to learn unit testing, and have this super simple class, with unit test: </p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>I'm getting null reference exceptions. It's related to using <code>this.Url()</code> without an <code>HttpContext</code> in the unit test, I believe.</p>
  
  <p>How can I get the unit test to pass while still using my <code>this.Url()</code>? I'm fine with using Moq. :)</p>