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, "<testValue"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue>")); CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue>"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, @"""testValue")); CheckAttributes(instance, 1, firstAlowedAttributeName, ""testValue"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue'tv")); CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue'tv"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, "testValue&tv")); CheckAttributes(instance, 1, firstAlowedAttributeName, "testValue&tv"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, @"<""testValue&tv'2"">")); CheckAttributes(instance, 1, firstAlowedAttributeName, "<"testValue&tv'2">"); instance.AddAttribute(new Fb2Attribute(firstAlowedAttributeName, " test value with whitespace ")); CheckAttributes(instance, 1, firstAlowedAttributeName, " test value with whitespace "); }
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"); }