public void CheckRequired() { var tag = new ForEach(); try { RequiredAttribute.Check(tag); Assert.Fail("Expected exception"); } catch (TagException Te) { Assert.That(Te.Message, Is.EqualTo( TagException.MissingRequiredAttribute(typeof (ForEach), "Source", "Select").Message)); } tag.Select = new MockAttribute(new Constant("AList")); tag.Source = new MockAttribute(new Constant("ASource")); RequiredAttribute.Check(tag); }
public void LoopNoBody() { var tag = new ForEach(); tag.Select = new MockAttribute(new Constant("//value")); tag.Source = new MockAttribute(new Constant("xml")); Assert.That(tag.Evaluate(_model), Is.EqualTo(String.Empty)); }
public void LoopWithStepAndBodyWithFilterInSelect() { var tag = new ForEach(); tag.Select = new MockAttribute(new Constant("//value[@flag=\"uppercase\"]")); tag.Source = new MockAttribute(new Constant("xml")); tag.Body = new TemplateAttribute(new Formatter("<x:out source=\"Item\" select=\".\"/>").Parse().ParsedTemplate); Assert.That(tag.Evaluate(_model), Is.EqualTo("ACEGIKMOQSUWY")); }
public void LoopWithStepAndBeginBody() { var tag = new ForEach(); tag.Select = new MockAttribute(new Constant("//value")); tag.Source = new MockAttribute(new Constant("xml")); tag.Body = new TemplateAttribute(new Formatter("<x:out source=\"Item\" select=\".\"/>").Parse().ParsedTemplate); tag.Begin = new MockAttribute(new Constant("13")); tag.Step = new MockAttribute(new Constant("2")); Assert.That(tag.Evaluate(_model), Is.EqualTo("nprtvxz")); }
public void LoopWithEvaluatingBody() { var tag = new ForEach(); tag.Select = new MockAttribute(new Constant("//value")); tag.Source = new MockAttribute(new Constant("xml")); tag.Body = new TemplateAttribute(new Formatter("<x:out source=\"Item\" select=\".\"/>").Parse().ParsedTemplate); Assert.That(tag.Evaluate(_model), Is.EqualTo("AbCdEfGhIjKlMnOpQrStUvWxYz")); }
public void LoopWithComplexStatusBody() { var tag = new ForEach(); tag.Select = new MockAttribute(new Constant("//value")); tag.Source = new MockAttribute(new Constant("xml")); tag.End = new MockAttribute(new Constant("7")); tag.Body = new TemplateAttribute(new Formatter("[${Status.Index}/${Status.Count}]").Parse().ParsedTemplate); Assert.That(tag.Evaluate(_model), Is.EqualTo("[0/26][1/26][2/26][3/26][4/26][5/26][6/26]")); }