public void Setup() { _autoSubstitute = AutoSubstituteContainer.Create(); _h = _autoSubstitute.ResolveAndSubstituteFor <HtmlHelper <TestFieldViewModel> >(); _t = _autoSubstitute.Resolve <IFormTemplate>(); _t.BeginForm(Action, Method, _htmlAttributes, Enctype).Returns(_beginHtml); _t.EndForm().Returns(_endHtml); }
public void Setup() { _autoSubstitute = AutoSubstituteContainer.Create(); _h = _autoSubstitute.ResolveAndSubstituteFor<HtmlHelper<TestFieldViewModel>>(); _t = _autoSubstitute.Resolve<IFormTemplate>(); _t.BeginForm(Action, Method, _htmlAttributes, Enctype).Returns(_beginHtml); _t.EndForm().Returns(_endHtml); }
/// <summary> /// Construct a Chameleon Form. /// Note: Contains a call to the virtual method Write. /// </summary> /// <param name="helper">The HTML Helper for the current view</param> /// <param name="template">A template renderer instance to use to render the form</param> /// <param name="action">The action the form should submit to</param> /// <param name="method">The HTTP method the form submission should use</param> /// <param name="htmlAttributes">Any HTML attributes the form should use expressed as an anonymous object</param> /// <param name="enctype">The encoding type the form submission should use</param> public Form(HtmlHelper <TModel> helper, IFormTemplate template, string action, FormMethod method, HtmlAttributes htmlAttributes, EncType?enctype) { HtmlHelper = helper; Template = template; // ReSharper disable DoNotCallOverridableMethodsInConstructor // Write method is virtual to allow it to be mocked for testing Write(Template.BeginForm(action, method, htmlAttributes, enctype)); // ReSharper restore DoNotCallOverridableMethodsInConstructor }
public void Setup() { _context = new MvcTestContext(); var viewContext = _context.GetViewTestContext <TestFieldViewModel>(); _h = viewContext.HtmlHelper; _t = Substitute.For <IFormTemplate>(); _t.BeginForm(Action, Method, _htmlAttributes, Enctype).Returns(_beginHtml); _t.EndForm().Returns(_endHtml); }
/// <summary> /// Construct a Chameleon Form. /// Note: Contains a call to the virtual method Write. /// </summary> /// <param name="helper">The HTML Helper for the current view</param> /// <param name="template">A template renderer instance to use to render the form</param> /// <param name="action">The action the form should submit to</param> /// <param name="method">The HTTP method the form submission should use</param> /// <param name="htmlAttributes">Any HTML attributes the form should use expressed as an anonymous object</param> /// <param name="enctype">The encoding type the form submission should use</param> /// <param name="outputAntiforgeryToken">Whether or not to output an antiforgery token in the form; defaults to null which will output a token if the method isn't GET</param> public Form(IHtmlHelper <TModel> helper, IFormTemplate template, string action, FormMethod method, HtmlAttributes htmlAttributes, EncType?enctype, bool?outputAntiforgeryToken) { _outputAntiforgeryToken = outputAntiforgeryToken ?? method != FormMethod.Get; helper.ViewData[Constants.ViewDataFormKey] = this; HtmlHelper = helper; Template = template; // ReSharper disable DoNotCallOverridableMethodsInConstructor // Write method is virtual to allow it to be mocked for testing Write(Template.BeginForm(action, method, htmlAttributes, enctype)); // ReSharper restore DoNotCallOverridableMethodsInConstructor }