public void any_attribute_with_simple_types_is_created_automatically()
        {
            var attribs = new XhtmlAttributeCollection();
            attribs.Count.ShouldBe(0);

            attribs.SetAttribute("name", "value");

            attribs["name"].ShouldBeOfType<IAttribute<string>>();
        }
예제 #2
0
        public void any_attribute_with_simple_types_is_created_automatically()
        {
            var attribs = new XhtmlAttributeCollection();

            attribs.Count.ShouldBe(0);

            attribs.SetAttribute("name", "value");

            attribs["name"].ShouldBeAssignableTo <IAttribute <string> >();
        }
        public void attributes_not_in_initial_list_are_added_as_generic_strings()
        {
            var attribs = new XhtmlAttributeCollection
            {
                AllowedAttributes = new Dictionary<string, Func<IAttribute>>
                {
                    {"name", () => new PrimaryTypeAttributeNode<string>("name")},
                    {"value", () => new PrimaryTypeAttributeNode<int?>("value")}
                }
            };

            attribs.SetAttribute("name", "a name");
            attribs.SetAttribute<int?>("value", 3);

            attribs["name"].SerializedValue.ShouldBe("a name");
            attribs["value"].SerializedValue.ShouldBe("3");

            attribs.SetAttribute("unknownValue", "25");

            attribs["unknownValue"].SerializedValue.ShouldBe("25");
        }
예제 #4
0
        public void attributes_not_in_initial_list_are_added_as_generic_strings()
        {
            var attribs = new XhtmlAttributeCollection
            {
                AllowedAttributes = new Dictionary <string, Func <IAttribute> >
                {
                    { "name", () => new PrimaryTypeAttributeNode <string>("name") },
                    { "value", () => new PrimaryTypeAttributeNode <int?>("value") }
                }
            };

            attribs.SetAttribute("name", "a name");
            attribs.SetAttribute <int?>("value", 3);

            attribs["name"].SerializedValue.ShouldBe("a name");
            attribs["value"].SerializedValue.ShouldBe("3");

            attribs.SetAttribute("unknownValue", "25");

            attribs["unknownValue"].SerializedValue.ShouldBe("25");
        }