My Page has following Hidden Field
<%= Html.Hidden("SessionId", Model.Form.UniqueSessionId) %>
My Controller
public class SomeController
{
public ActionResult Index()
{
var somemode = new GetSomeModel();
return View(somemodel);
}
}
I wanna be able to test whether the view has the hidden field
protected SomeController controller;
protected void SetupController()
{
controller = new SomeController()
}
[Test]
public void view_has_hidden_field_for_SessionId()
{
ViewResult result = controller.Index() as ViewResult;
Assert.IsTrue(result.contains("<input type="hidden" id="SessionId" />"));
}
Question is: How can i render view as string? Any help?