コード例 #1
0
        public void WithEmptyNameDoesNotAddAttribute()
        {
            string name = string.Empty;
            string value = "Value";

            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
            var result = builder.AddMultiValueAttribute( name, value );

            Assert.AreSame( builder, result );
            Assert.IsFalse( builder.Attributes.ContainsKey( name ) );
        }
コード例 #2
0
        public void AddsAttributeCorrectly()
        {
            string name = "Name";
            string value = "Value";

            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
            var result = builder.AddMultiValueAttribute( name, value );

            Assert.AreSame( builder, result );

            AttributeValueCollection attributeValues = builder.Attributes[ name ] as AttributeValueCollection;
            Assert.IsNotNull( attributeValues );
            Assert.AreEqual( value, attributeValues[ 0 ] );
        }
コード例 #3
0
        public void WithMultipleValuesAddsAttributeCorrectly()
        {
            string name = "Name";
            string[] values = new string[]
            {
                "Value1",
                "Value2"
            };

            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
            var result = builder.AddMultiValueAttribute( name, values );

            Assert.AreSame( builder, result );

            AttributeValueCollection attributeValues = builder.Attributes[ name ] as AttributeValueCollection;
            Assert.IsNotNull( attributeValues );
            Assert.AreEqual( values[ 0 ], attributeValues[ 0 ] );
            Assert.AreEqual( values[ 1 ], attributeValues[ 1 ] );
        }
コード例 #4
0
        public void WithNullNameDoesNotAddAttribute()
        {
            string name = null;
            string value = "Value";

            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
            var result = builder.AddMultiValueAttribute( name, value );

            Assert.AreSame( builder, result );
            Assert.AreEqual( 0, builder.Attributes.Count );
        }