コード例 #1
0
 public void Should_be_able_to_Generate_a_File_Input_Button()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string FileInput = htmlhelper.FileFor(P => P.fileFormat).ToString();
     var cq = CQ.Create(FileInput);
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.File);
 }
コード例 #2
0
 public void Should_be_able_to_Generate_a_Reset_Button()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string htmlTextBox = htmlhelper.ResetButton("SomeName").ToString();
     var cq = CQ.Create(htmlTextBox);
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.RESET);
 }
コード例 #3
0
 public void Should_be_able_to_Generate_a_Hidden_Field_With_Model_And_Property()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string FileInput = htmlhelper.Hidden(P => P.Name).ToString();
     var cq = CQ.Create(FileInput);
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.HIDDEN);
 }
コード例 #4
0
 public void Should_be_able_to_Generate_a_Submit_Button()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string submitButton = htmlhelper.Submit("SomeName").ToString();
     var cq = CQ.Create(submitButton);
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.SUBMIT);
 }
コード例 #5
0
 public static ValidationBehavior ValidateOn(this FluentHtmlHelper html, string name)
 {
     if (!String.IsNullOrEmpty(name))
     {
         return(new ValidationBehavior(() => GetModelState(html, name)));
     }
     return(null);
 }
コード例 #6
0
 public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_CheckBox()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string htmlTextBox = htmlhelper.CheckBoxFor<Customer>(p => p.IsChecked).ToString();
     var cq = CQ.Create(htmlTextBox);
     cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("IsChecked");
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.CHECKBOX);
 }
コード例 #7
0
 public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_Html_back()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string htmlTextBox = htmlhelper.TextBoxFor<Customer>(p => p.Name).Disabled(true).Class("Required").ToString();
     var cq = CQ.Create(htmlTextBox);
     cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("Name");
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be("text");
 }
コード例 #8
0
        private static ModelState GetModelState(FluentHtmlHelper html, string name)
        {
            ModelState state;

            if (html.ViewData.ModelState.TryGetValue(name, out state))
            {
                return(state);
            }
            return(null);
        }
コード例 #9
0
        public static ValidationMessage ValidationMessage(this FluentHtmlHelper html, string name)
        {
            ModelState state   = GetModelState(html, name);
            string     message = null;

            if (state != null && state.Errors != null && state.Errors.Count > 0)
            {
                message = GetUserErrorMessageOrDefault(html.ViewContext.HttpContext, state.Errors[0], state);
            }
            return(new ValidationMessage().Value(message));
        }
コード例 #10
0
 public void Should_be_able_to_Create_A_Tag_with_the_Link()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     htmlhelper.Request = new HttpRequestMessage();
     htmlhelper.Request.RequestUri = new Uri("http://localhost/api/home");
     HttpConfiguration configuration = new HttpConfiguration();
     htmlhelper.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration;
     htmlhelper.Request.AddDefaultRoute();
     string htmlanchortag = htmlhelper.Action<HomeController>(p => p.Get()).ToString();
     var cq = CQ.Create(htmlanchortag);
     cq.Attr(HTMLATTRIBUTE.HREF).Should().Be("/api/home");
 }
コード例 #11
0
 public void Should_be_able_Parse_the_RazorMVCtemplate_With_FluentTextboxHelper()
 {
     var templateConfiguration = new TemplateServiceConfiguration();
     templateConfiguration.BaseTemplateType = typeof(MvcTemplate<>);
     templateConfiguration.Namespaces.Add("FluentHtml");
     templateConfiguration.Namespaces.Add("FluentHtml.Intgeration");
     templateConfiguration.EncodedStringFactory = new RawStringFactory();
     using (var template = new TemplateService(templateConfiguration))
     {
         FluentHtmlHelper<Customer> HTML = new FluentHtmlHelper<Customer>();
         string inputTemplate = "@HTML.TextBoxFor(p => p.Name).Disabled(true);";
         string output = template.Parse(inputTemplate, new Customer());
         CQ.Create(output).Attr("name").Should().Be("Name");
     }
 }
コード例 #12
0
 public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_RadioButton()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string htmlTextBox = htmlhelper.RadioButtonFor<Customer>(p => p.IsChecked).ToString();
     var cq = CQ.Create(htmlTextBox);
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.RADIO);
 }
コード例 #13
0
 public static Literal Literal(this FluentHtmlHelper html, string name)
 {
     return(new Literal().Value(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name)));
 }
コード例 #14
0
 public void Should_be_able_to_pass_in_the_Model_and_Property_and_Get_The_Password()
 {
     FluentHtmlHelper<Customer> htmlhelper = new FluentHtmlHelper<Customer>();
     string htmlTextBox = htmlhelper.PasswordFor<Customer>(p => p.Name).ToString();
     var cq = CQ.Create(htmlTextBox);
     cq.Attr(HTMLATTRIBUTE.NAME).Should().Be("Name");
     cq.Attr(HTMLATTRIBUTE.TYPE).Should().Be(HTMLATTRIBUTE.PASSWORD);
 }
コード例 #15
0
 public static TextArea TextArea(this FluentHtmlHelper html, string name)
 {
     return(new TextArea(name).Value(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name))
            .Do(ValidateOn(html, name)));
 }
コード例 #16
0
 public static SubmitButton SubmitButton(this FluentHtmlHelper html, string name)
 {
     return(new SubmitButton(name));
 }
コード例 #17
0
 public static RadioButton RadioButton(this FluentHtmlHelper html, string name)
 {
     return(new RadioButton(name).SelectedValue(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name)));
 }
コード例 #18
0
 public static CheckBox CheckBox(this FluentHtmlHelper html, string name)
 {
     return(new CheckBox(name).SelectedValue(String.IsNullOrEmpty(name) ? null : html.ViewData.Eval(name)));
 }
コード例 #19
0
 public static Literal Literal(this FluentHtmlHelper html)
 {
     return(new Literal());
 }