Beispiel #1
0
 public void IfApplies()
 {
     var tag = new If();
     tag.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     tag.Source = new MockAttribute(new Constant("xml"));
     tag.Body = new MockAttribute(new Constant("Show me"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo("Show me"));
 }
Beispiel #2
0
 public void CheckRequired()
 {
     var tag = new If();
     try
     {
         RequiredAttribute.Check(tag);
         Assert.Fail("Expected Exception");
     }
     catch (TagException Te)
     {
         Assert.That(Te.Message,
                     Is.EqualTo(TagException.MissingRequiredAttribute(typeof (If), "Source", "Select").Message));
     }
     tag.Select = new MockAttribute(new Constant("a"));
     tag.Source = new MockAttribute(new Constant("a"));
     RequiredAttribute.Check(tag);
 }
Beispiel #3
0
 public void IfDontApplyBecauseOfNullReturningXPath()
 {
     var tag = new If();
     tag.Select = new MockAttribute(new Constant("/results/value[position()=99]"));
     tag.Source = new MockAttribute(new Constant("xml"));
     tag.Body = new MockAttribute(new Constant("Show me"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
 }
Beispiel #4
0
 public void IfShouldThrowExceptionWhenNoneBoolIsFound()
 {
     var tag = new If
           {
               Select = new MockAttribute(new Constant("/results/value[position()=3]")),
               Source = new MockAttribute(new Constant("xml")),
               Body = new MockAttribute(new Constant("Show me"))
           };
     try
     {
         tag.Evaluate(_model);
         Assert.Fail("Expected exception");
     }
     catch (TagException e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(TagException.IllegalXPath(new FormatException()).Message);
         Assert.That(e.Message.StartsWith(TagException.IllegalXPath(new FormatException("")).Message));
     }
 }
Beispiel #5
0
 public void IfShouldThrowExceptionWhenEmptyStringIsFound()
 {
     var tag = new If();
     tag.Select = new MockAttribute(new Constant("/results/value[position()=4]"));
     tag.Source = new MockAttribute(new Constant("xml"));
     tag.Body = new MockAttribute(new Constant("Show me"));
     Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty));
 }