コード例 #1
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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);
 }
コード例 #2
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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));
 }
コード例 #3
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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"));
 }
コード例 #4
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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"));
 }
コード例 #5
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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"));
 }
コード例 #6
0
ファイル: ForEachTest.cs プロジェクト: rslijp/sharptiles
 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]"));
 }