Ejemplo n.º 1
0
        public void ListBoxWithIEnumerableSelectListItemSelectsDefaultFromViewData()
        {
            // Arrange
            ViewDataDictionary vdd = new ViewDataDictionary {
                { "foo", "123456789" }
            };
            HtmlHelper helper = HtmlHelperTest.GetHtmlHelper(vdd);

            // Act
            string html = helper.ListBox("foo", MultiSelectListTest.GetSampleIEnumerableObjects());

            // Assert
            Assert.AreEqual(
                @"<select id=""foo"" multiple=""multiple"" name=""foo""><option value=""123456789"">John</option>
<option value=""987654321"">Jane</option>
<option value=""111111111"">Joe</option>
</select>",
                html);
        }
Ejemplo n.º 2
0
        public void DropDownListWithIEnumerableSelectListItem()
        {
            // Arrange
            ViewDataDictionary vdd = new ViewDataDictionary {
                { "foo", MultiSelectListTest.GetSampleIEnumerableObjects() }
            };
            HtmlHelper helper = HtmlHelperTest.GetHtmlHelper(vdd);

            // Act
            string html = helper.DropDownList("foo");

            // Assert
            Assert.AreEqual(
                @"<select id=""foo"" name=""foo""><option value=""123456789"">John</option>
<option value=""987654321"">Jane</option>
<option selected=""selected"" value=""111111111"">Joe</option>
</select>",
                html);
        }