Ejemplo n.º 1
0
        public void SanitizedId()
        {
            var helper = FakeHtmlHelper.New(new ExamplePostModel());

            var tag = helper.Select(f => f.InputsArray[1].String2, new Option[0]).RenderTag();

            tag.Attr("name").Should().Be("InputsArray[1].String2");
            tag.Attr("id").Should().Be("InputsArray_1__String2");
        }
Ejemplo n.º 2
0
        public void FormFor()
        {
            var html = FakeHtmlHelper.New(new TestViewModel());

            html.SetRawUrl("http://fake.url");

            var form = html.FormFor(html.ViewData.Model.Cmd);

            form.Action().Should().Be("http://fake.url:80/");
        }
Ejemplo n.º 3
0
        public void AttemptedValue()
        {
            var helper = FakeHtmlHelper.New(new ExamplePostModel());

            helper.ViewData.ModelState.SetModelValue("String2", new ValueProviderResult("raw value"), "attempted value");

            var input = helper.InputText(f => f.String2);

            input.Value().Should().Be("attempted value");
        }
Ejemplo n.º 4
0
        public void Cancel_HasDefaultUrl_When_DefaultSupplied()
        {
            var helper = FakeHtmlHelper.New();

            var linkButton = helper.LinkButtonCancelModal().DefaultModalReturn("~/default");

            var html = linkButton.ToHtmlString();

            html.Should().Contain("href=\"/default\"");
        }
Ejemplo n.º 5
0
        public void HelperStringsAreEscaped()
        {
            var helper = FakeHtmlHelper.New <object>(null);

            var linkButton = helper.LinkButton("<b>bold</b>", "#");

            var html = linkButton.ToHtmlString();

            html.Should().Contain("&lt;b&gt;");
        }
Ejemplo n.º 6
0
        public void Cancel_HasHash_When_MissingReturnUrl_And_NoDefaultSupplied()
        {
            var helper = FakeHtmlHelper.New();

            var linkButton = helper.LinkButtonCancelModal();

            var html = linkButton.ToHtmlString();

            html.Should().Contain("href=\"#\"");
        }
Ejemplo n.º 7
0
        public void CanContainHtmlContent()
        {
            var helper = FakeHtmlHelper.New();

            var linkButton = helper.LinkButton(helper.Raw("<i>italic</i>"), "~/home");

            var html = linkButton.ToHtmlString();

            html.Should().Contain("<i>italic</i>");
        }
Ejemplo n.º 8
0
        public void CanContainHtmlContent()
        {
            var helper = FakeHtmlHelper.New <object>(null);

            var button = helper.ButtonSubmit(helper.Raw("<b>bold</b>"));

            var html = button.ToHtmlString();

            html.Should().Contain("<b>bold</b>");
        }
Ejemplo n.º 9
0
        public void FormGroup()
        {
            var model = new ExamplePostModel();

            var helper = FakeHtmlHelper.New(model);

            var group = helper.FormGroup("test label", fg => fg.InputText(f => f.String));
            var tags  = Render(group);

            tags.Label.Attr("for").Should().Be(tags.Control.Id());
        }
Ejemplo n.º 10
0
        public void Cancel_UsesReturnUrl()
        {
            var helper = FakeHtmlHelper.New()
                         .SetRawUrl("test?modalReturnUrl=" + HttpUtility.UrlEncode("http://return.url"));

            var linkButton = helper.LinkButtonCancelModal().DefaultModalReturn("~/default");

            var html = linkButton.ToHtmlString();

            html.Should().Contain("href=\"http://return.url\"");
        }
Ejemplo n.º 11
0
        public void ControlStringsAreEscaped()
        {
            var helper = FakeHtmlHelper.New <object>(null);

            var linkButton = new LinkButton(helper, helper.Raw("test"))
                             .Content("<b>bold</b>");

            var html = linkButton.ToHtmlString();

            html.Should().Contain("&lt;b&gt;");
        }
Ejemplo n.º 12
0
        public void GenericViewData()
        {
            var helper = FakeHtmlHelper.New(new ReflectionHelperTests());

            helper.ViewData.ModelState.SetModelValue("Test", new ValueProviderResult("rawValue"), "attempted value");

            var genericViewData = helper.ViewData;
            var genericViewBag  = helper.ViewBag;

            helper.ViewData.ModelState.Keys.Count().Should().Be(1);

            var untypedHelper = (helper as IHtmlHelper);

            untypedHelper.GenericViewData().ModelState.Keys.Count().Should().Be(1);

            untypedHelper.GenericViewData().Should().BeSameAs(genericViewData);

            var viewBagEquality = (bool)object.ReferenceEquals(untypedHelper.GenericViewBag(), genericViewBag);

            viewBagEquality.Should().BeTrue();
        }
Ejemplo n.º 13
0
 public MyControl() : base(FakeHtmlHelper.New())
 {
 }
Ejemplo n.º 14
0
 public static FakeHtmlHelper <T> Helper <T>(this T model)
 {
     return(FakeHtmlHelper.New(model));
 }