public void CheckSelectNoneExistingNode() { var tag = new Out(); tag.Select = new MockAttribute(new Constant("//note[@id=\"3\"]/body")); tag.Source = new MockAttribute(new Constant("xml")); Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty)); }
public void CheckSelect() { var tag = new Out(); tag.Select = new MockAttribute(new Constant("//note/to")); tag.Source = new MockAttribute(new Constant("xml")); Assert.That(tag.Evaluate(_model), Is.EqualTo("Tove, John")); }
public void BadTag() { var tag = new Choose(); var outTag = new Out(); try { tag.AddNestedTag(outTag); } catch (TagException Te) { Assert.AreEqual(Te.Message, TagException.OnlyNestedTagsOfTypeAllowed(typeof (Out), typeof (When), typeof (When))); } }
public void CheckRequired() { var tag = new Out(); try { RequiredAttribute.Check(tag); Assert.Fail("Expected Exception"); } catch (TagException Te) { Assert.That(Te.Message, Is.EqualTo(TagException.MissingRequiredAttribute(typeof (Out), "Source", "Select").Message)); } tag.Select = new MockAttribute(new Constant("a")); tag.Source = new MockAttribute(new Constant("a")); RequiredAttribute.Check(tag); }
public void CheckSelectWrongXpathSyntax() { var tag = new Out(); tag.Select = new MockAttribute(new Constant("//note[@id=\"3\"/body")); tag.Source = new MockAttribute(new Constant("xml")); try { Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty)); Assert.Fail("Expected exception"); } catch (TagException XPe) { Assert.That(XPe.Message.StartsWith(TagException.IllegalXPath(new Exception("")).Message), Is.True); } }
public void CheckSelectOneNodeNoEscapingSingleSlash() { var tag = new Out(); tag.Select = new MockAttribute(new Constant("//notes/note[@id=\"2\"]/body")); tag.Source = new MockAttribute(new Constant("xml")); tag.EscapeXml = new MockAttribute(new Constant("false")); Assert.That(tag.Evaluate(_model), Is.EqualTo("Read the previous memo & note")); }
public void CheckSelectOneNodeExplicitEscaping() { var tag = new Out(); tag.Select = new MockAttribute(new Constant("//note[@id=\"2\"]/body")); tag.Source = new MockAttribute(new Constant("xml")); tag.EscapeXml = new MockAttribute(new Constant("true")); Assert.That(tag.Evaluate(_model), Is.EqualTo("Read the previous memo & note")); }
public void CheckSelectNoXPath() { var tag = new Out(); tag.Source = new MockAttribute(new Constant("xmlnonexisting")); Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty)); }