public void AddAttribute() { Assert.That(_tag.Attributes, Is.Empty); _tag.AddAttribute("key1"); Assert.That(_tag.Attributes["key1"], Is.Null); _tag.AddAttribute("key2", "<<\"asd"); Assert.That(_tag.Attributes["key2"], Is.EqualTo(new AttributeEncoder().Encode("<<\"asd"))); _tag.AddAttribute("key3", "<<\"asd", new PassThroughEncoder()); Assert.That(_tag.Attributes["key3"], Is.EqualTo(new PassThroughEncoder().Encode("<<\"asd"))); Assert.That(_tag.Attributes.Count, Is.EqualTo(3)); }
public void Render() { RenderAssertion(new TestTag("tagname"), "<tagname></tagname>"); RenderAssertion(new TestTag("tagname", TagRenderMode.SelfClosing), "<tagname>"); var tag = new TestTag("tagname"); tag.AddAttribute("attr1"); tag.AddAttribute("attr2", "value of attr"); RenderAssertion(tag, "<tagname attr1 attr2=\"value of attr\"></tagname>"); tag = new TestTag("tagname"); tag.AddAttribute("attr1"); tag.AddInnerHtml(new TestTag("innerTag", TagRenderMode.SelfClosing)); RenderAssertion(tag, "<tagname attr1><innerTag></tagname>"); }
protected void AssertAttributeAdded(Action <T> actionToTest, string expectedResult) { Tag.Setup(t => t.AddAttribute(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <StringEncoder>())) .Callback((string k, string v, StringEncoder enc) => _testTag.AddAttribute(k, v, enc)).Verifiable(); actionToTest.Invoke(Tag.Object); Assert.AreEqual(expectedResult, _testTag.ToString()); }