I'm using restful routing module for asp.net mvc and very happy with it. But I can't get one thing. For example I had a controller action like this:
public ActionResult Index()
{
if (Request.IsAjaxRequest())
return PartialView();
return View();
}
And had no problem with writing a spec like this:
[Subject(typeof(LotsController))]
public class When_Index_called
{
static LotsController controller;
static ActionResult actionResult;
Establish context = () => {
controller = mocker.Create();
controller.ControllerContext = Contexts.Controller.Default;
};
Because of = () => actionResult = controller.Index();
It should_render_view = () => actionResult.AssertViewRendered().ForViewWithDefaultName();
But with use of rest, I want to have an Index method like this:
public ActionResult Index()
{
return RespondTo(format => {
format.Html = () => {
if (Request.IsAjaxRequest())
return PartialView();
return View();
};
format.Json = () => Json(new { });
});
}
Sure that previous spec fails, because action result is not of type ViewResult, its of type FormatResult. FormatResult by itself overrides ExecuteResult method that returns void. How can I unit test such case if I want to verify action result types and data inside FormatResult?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)