Exemple #1
0
 public void CheckWhenRequired()
 {
     var tag = new When();
     try
     {
         RequiredAttribute.Check(tag);
         Assert.Fail("Expected exception");
     }
     catch (TagException Te)
     {
         Assert.That(Te.Message,
                     Is.EqualTo(TagException.MissingRequiredAttribute(typeof (When), "Source", "Select").Message));
     }
     tag.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     tag.Source = new MockAttribute(new Constant("xml"));
     RequiredAttribute.Check(tag);
 }
Exemple #2
0
 public void ChooseThreeTrueAndOtherWise()
 {
     var tag = new Choose();
     var whenTrue = new When();
     whenTrue.Body = new MockAttribute(new Constant("True1"));
     whenTrue.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     whenTrue.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenTrue);
     var whenTrue2 = new When();
     whenTrue2.Body = new MockAttribute(new Constant("True2"));
     whenTrue2.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     whenTrue2.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenTrue2);
     var whenTrue3 = new When();
     whenTrue3.Body = new MockAttribute(new Constant("True3"));
     whenTrue3.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     whenTrue3.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenTrue2);
     var otherwise = new Otherwise();
     otherwise.Body = new MockAttribute(new Constant("Ötherwise"));
     tag.AddNestedTag(otherwise);
     Assert.That(tag.Evaluate(_model), Is.EqualTo("True1"));
 }
Exemple #3
0
 public void ChooseTwoFalseAndOtherWise()
 {
     var tag = new Choose();
     var whenFalse = new When();
     whenFalse.Body = new MockAttribute(new Constant("Body1"));
     whenFalse.Select = new MockAttribute(new Constant("/results/value[position()=2]"));
     whenFalse.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenFalse);
     var whenFalse2 = new When();
     whenFalse2.Body = new MockAttribute(new Constant("Body2"));
     whenFalse2.Select = new MockAttribute(new Constant("/results/value[position()=2]"));
     whenFalse2.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenFalse2);
     var otherwise = new Otherwise();
     otherwise.Body = new MockAttribute(new Constant("Body3"));
     tag.AddNestedTag(otherwise);
     Assert.That(tag.Evaluate(_model), Is.EqualTo("Body3"));
 }
Exemple #4
0
 public void ChooseOnlyOneWhenTrue()
 {
     var tag = new Choose();
     var whenTrue = new When();
     whenTrue.Body = new MockAttribute(new Constant("Body1"));
     whenTrue.Select = new MockAttribute(new Constant("/results/value[position()=1]"));
     whenTrue.Source = new MockAttribute(new Constant("xml"));
     tag.AddNestedTag(whenTrue);
     Assert.That(tag.Evaluate(_model), Is.EqualTo("Body1"));
 }