Ejemplo n.º 1
0
    public void ShouldNotChangeResultIfValidModel([Frozen]ControllerBase controller, [Substitute]ActionExecutingContext filterContext, ValidateModelAttribute validateModel)
    {
      filterContext.Controller = controller;

      validateModel.OnActionExecuting(filterContext);

      filterContext.Result.Should().BeNull();
    }
Ejemplo n.º 2
0
    public void ShouldChangeResultIfInvalidModel([Frozen]ControllerBase controller, [Substitute]ActionExecutingContext filterContext, ValidateModelAttribute validateModel)
    {
      filterContext.Controller = controller;
      filterContext.Controller.ViewData.ModelState.AddModelError("error","error");

      validateModel.OnActionExecuting(filterContext);

      filterContext.Result.Should().BeOfType<ViewResult>().Which.ViewData.ShouldBeEquivalentTo(filterContext.Controller.ViewData);
    }