示例#1
0
        public void a_nullable_enum_property_sets_to_null_selects_an_empty_option_element_in_first_position()
        {
            var target = new Test();
            var select = XHtml.Select(() => target.NullableEnum);

            select.Name.ShouldBe("Test.NullableEnum");
            select.ChildNodes.Cast <IOptionElement>().SingleOrDefault(x => x.InnerText == "")
            .ShouldNotBeNull()
            .Selected.ShouldBeTrue();
            select.ChildNodes.Count.ShouldBe(Enum.GetNames(typeof(AttributeTargets)).Length + 1);
        }
示例#2
0
        public void an_enum_property_gets_enumeration_values_set()
        {
            var target = new Test {
                Enum = AttributeTargets.All
            };
            var select = XHtml.Select(() => target.Enum);

            select.Name.ShouldBe("Test.Enum");
            select.ChildNodes.Cast <IOptionElement>().SingleOrDefault(x => x.InnerText == "All")
            .ShouldNotBeNull()
            .Selected.ShouldBeTrue();
            select.ChildNodes.Count.ShouldBe(Enum.GetNames(typeof(AttributeTargets)).Length);
        }
示例#3
0
        public void a_dictionary_is_rendered_as_options()
        {
            var t      = new Test();
            var select = XHtml.Select(() => t.Enum,
                                      new Dictionary <string, string> {
                { "key1", "value1" }, { "key2", "value2" }
            });
            var first = select.ChildNodes[0].ShouldBeOfType <IOptionElement>();

            first.InnerText.ShouldBe("value1");
            first.Value.ShouldBe("key1");

            var second = select.ChildNodes[1].ShouldBeOfType <IOptionElement>();

            second.InnerText.ShouldBe("value2");
            second.Value.ShouldBe("key2");
        }