Example #1
0
        protected ActionResult GetPreviousView <T>(int id, FormSection section, T model) where T : IValidatable
        {
            if (!FormDefinition.CanViewPage(section, id, model))
            {
                return(RedirectToPreviousPossibleView(id, section, model));
            }

            var viewPath  = GetViewPath(section, id);
            var viewModel = FormDefinition.GetViewModel(section, id, model);

            return(View(viewPath, viewModel));
        }
        public void it_returns_null_if_a_non_present_view_model_is_requested()
        {
            const FormSection emptySection      = FormSection.OrganisationDetails;
            const string      invalidActionName = "not present";

            config.Fields = new Dictionary <FormSection, FormPageDefinition[]>
            {
                {
                    emptySection,
                    new[]
                    {
                        new FormPageDefinition()
                    }
                }
            };

            var result = form.GetViewModel(emptySection, invalidActionName, new ExampleViewModel());

            Assert.IsNull(result);
        }