title: Unit testing Html.Action and PartialView
body: <p>I want to test some controller actions whose views contain Html.Action with PartialViews. But when debugging them I don't get the breakpoint that is in the action that I want to call through the view.<br>
  Here is my controller code:</p>
  
  <pre><code>public class SomeController
  { 
      public ActionResult MyAction()
      {
          return View();
      }
  
      public PartialViewResult SubAction()
      {
          return PartialView();
      }
  }
  </code></pre>
  
  <p>The code in the MyAction view is simply:</p>
  
  <pre><code>@{
      ViewBag.Title = "MyAction";
  }
  @Html.Action("SubAction")
  </code></pre>
  
  <p>With my TestMethod I'd like to check if the correct ViewName is returned:</p>
  
  <pre><code>[TestMethod]
  public void MyActionTest()
  {
      SomeController controller = new SomeController();
      ViewResult result = controller.MyAction() as ViewResult;
      Assert.IsNotNull(result, "The result is not a view result.");
      Assert.AreEqual("some expected name", result.ViewName);
  }
  </code></pre>
  
  <p>Another problem is that the result.ViewName is empty here and I don't know why that is. So this is another question unanswered. That problem is why I tried to debug my unit test and recognized that I cannot break into SubAction().  </p>
  
  <p>Any suggestions about that?  </p>
  
  <p>Cheers,<br>
  Simon</p>