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")); }
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); }
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)); }
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)); } }
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)); }