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"); }
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/"); }
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"); }
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\""); }
public void HelperStringsAreEscaped() { var helper = FakeHtmlHelper.New <object>(null); var linkButton = helper.LinkButton("<b>bold</b>", "#"); var html = linkButton.ToHtmlString(); html.Should().Contain("<b>"); }
public void Cancel_HasHash_When_MissingReturnUrl_And_NoDefaultSupplied() { var helper = FakeHtmlHelper.New(); var linkButton = helper.LinkButtonCancelModal(); var html = linkButton.ToHtmlString(); html.Should().Contain("href=\"#\""); }
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>"); }
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>"); }
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()); }
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\""); }
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("<b>"); }
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(); }
public MyControl() : base(FakeHtmlHelper.New()) { }
public static FakeHtmlHelper <T> Helper <T>(this T model) { return(FakeHtmlHelper.New(model)); }