Beispiel #1
0
 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));
 }
Beispiel #2
0
 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"));
 }
Beispiel #3
0
 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)));
     }
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
 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);
     }
 }
Beispiel #6
0
 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"));
 }
Beispiel #7
0
 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"));
 }
Beispiel #8
0
 public void CheckSelectNoXPath()
 {
     var tag = new Out();
     tag.Source = new MockAttribute(new Constant("xmlnonexisting"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
 }