예제 #1
0
        public void AddAttribute_AllowedAttribute_EscapesAttributeValue_Works(Fb2Node instance)
        {
            instance.Should().NotBe(null);

            if (!instance.AllowedAttributes.Any())
            {
                return;
            }

            var firstAlowedAttributeName = instance.AllowedAttributes.First();

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "<testValue"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "&lt;testValue");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue>"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue&gt;");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, @"""testValue"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "&quot;testValue");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue'tv"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue&apos;tv");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue&tv"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue&amp;tv");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, @"<""testValue&tv'2"">"));
            CheckAttributes(instance, 1, firstAlowedAttributeName, "&lt;&quot;testValue&amp;tv&apos;2&quot;&gt;");

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, " test value with whitespace "));
            CheckAttributes(instance, 1, firstAlowedAttributeName, " test value with whitespace ");
        }
예제 #2
0
        public void AddAttribute_AllowedAttribute_Works(Fb2Node instance)
        {
            instance.Should().NotBe(null);

            if (!instance.AllowedAttributes.Any())
            {
                return;
            }

            var firstAlowedAttributeName = instance.AllowedAttributes.First();

            instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue"));

            var attributes = instance.Attributes;

            //attributes.Should().HaveCount(1).And.ContainKey(firstAlowedAttributeName);
            //attributes[firstAlowedAttributeName].Should().Be("testValue");
            attributes.Should().HaveCount(1).And.Contain((attr) => attr.Key == firstAlowedAttributeName);
            attributes[0].Value.Should().Be("testValue");
        }