// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. using System.Web.Mvc; using System.Web.Routing; using Microsoft.Web.UnitTestUtil; using Xunit; namespace Microsoft.Web.Mvc.Test { public class SubmitButtonExtensionsTest { [Fact] public void SubmitButtonRendersWithJustTypeAttribute() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton(); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithAttributesWithUnderscores() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton(null, "blah", new { foo_bar = "baz" }); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithNameRendersButtonWithNameAttribute() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("button-name"); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithIdDifferentFromNameRendersButtonWithId() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("button-name", "blah", new { id = "foo" }); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithNameAndTextRendersAttributes() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("button-name", "button-text"); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithNameAndValueRendersBothAttributes() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("button-name", "button-value", new { id = "button-id" }); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithNameAndIdRendersBothAttributesCorrectly() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("button-name", "button-value", new { id = "button-id" }); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithTypeAttributeRendersCorrectType() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("specified-name", "button-value", new { type = "not-submit" }); Assert.Equal("", button.ToHtmlString()); } [Fact] public void SubmitButtonWithNameAndValueSpecifiedAndPassedInAsAttributeChoosesSpecified() { HtmlHelper html = MvcHelper.GetHtmlHelper(new ViewDataDictionary()); MvcHtmlString button = html.SubmitButton("specified-name", "button-value", new RouteValueDictionary(new { name = "name-attribute-value", value = "value-attribute" })); Assert.Equal("", button.ToHtmlString()); } } }