public void RadioButtonWithEmptyNameThrows() { // Arrange HtmlHelper helper = new HtmlHelper(new ModelStateDictionary()); // Act and assert ExceptionAssert.ThrowsArgNullOrEmpty(() => helper.RadioButton(null, null), "name"); ExceptionAssert.ThrowsArgNullOrEmpty(() => helper.RadioButton(String.Empty, null), "name"); }
public void RadioButtonWithDefaultArguments() { // Arrange HtmlHelper helper = new HtmlHelper(new ModelStateDictionary()); // Act var html = helper.RadioButton("foo", "bar", true); // Assert Assert.AreEqual(@"<input checked=""checked"" id=""foo"" name=""foo"" type=""radio"" value=""bar"" />", html.ToHtmlString()); html = helper.RadioButton("foo", "bar", false); // Assert Assert.AreEqual(@"<input id=""foo"" name=""foo"" type=""radio"" value=""bar"" />", html.ToHtmlString()); }
public void RadioButtonWithDictionaryAttributes() { // Arrange HtmlHelper helper = new HtmlHelper(new ModelStateDictionary()); // Act var html = helper.RadioButton("foo", "bar", new Dictionary<string, object> { { "attr", "attr-value" } }); // Assert Assert.AreEqual(@"<input attr=""attr-value"" id=""foo"" name=""foo"" type=""radio"" value=""bar"" />", html.ToHtmlString()); }
public void RadioButtonUsesModelStateToAssignChecked() { // Arrange var modelState = new ModelStateDictionary(); modelState.SetModelValue("foo", "bar"); HtmlHelper helper = new HtmlHelper(modelState); // Act var html = helper.RadioButton("foo", "bar"); // Assert Assert.AreEqual(@"<input checked=""checked"" id=""foo"" name=""foo"" type=""radio"" value=""bar"" />", html.ToHtmlString()); }
public void RadioButtonWithoutModelStateDoesNotAffectChecked() { // Arrange HtmlHelper helper = new HtmlHelper(new ModelStateDictionary()); // Act var html = helper.RadioButton("foo", "bar", new { @checked = "checked" }); // Assert Assert.AreEqual(@"<input checked=""checked"" id=""foo"" name=""foo"" type=""radio"" value=""bar"" />", html.ToHtmlString()); }
public void RadioButtonOverwritesImplicitAttributes() { // Arrange HtmlHelper helper = new HtmlHelper(new ModelStateDictionary()); // Act var html = helper.RadioButton("foo", "foo-value", new { value="bazValue", type = "fooType", name = "bar" }); // Assert Assert.AreEqual(@"<input id=""foo"" name=""foo"" type=""fooType"" value=""foo-value"" />", html.ToHtmlString()); }
public void RadioButtonWithNonStringValue() { // Arrange var modelState = new ModelStateDictionary(); modelState.SetModelValue("foo", "bar"); HtmlHelper helper = new HtmlHelper(modelState); // Act var html = helper.RadioButton("foo", 2.53); // Assert Assert.AreEqual(@"<input id=""foo"" name=""foo"" type=""radio"" value=""2.53"" />", html.ToHtmlString()); }