Esempio n. 1
0
        public void LoopNoBody()
        {
            var tag = new ForEach();

            tag.Items = new MockAttribute(new Property("AList"));
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(String.Empty));
        }
Esempio n. 2
0
        public void LoopWithSimpleBody()
        {
            var tag = new ForEach();

            tag.Items = new MockAttribute(new Property("AList"));
            tag.Body  = new MockAttribute(new Property("Body"));
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(Body + Body + Body + Body + Body + Body + Body));
        }
Esempio n. 3
0
        public void LoopWithComplexStatusBody()
        {
            var tag = new ForEach();

            tag.Items = new MockAttribute(new Property("AList"));
            tag.Body  = new TemplateAttribute(new Formatter(ComplexStatusBody).Parse().ParsedTemplate);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("[0/7][1/7][2/7][3/7][4/7][5/7][6/7]"));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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"));
        }
Esempio n. 7
0
        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]"));
        }
Esempio n. 8
0
        public void LoopWithFirstEndAndStepComplexBody()
        {
            var tag = new ForEach();

            tag.Items = new MockAttribute(new Property("AList"));
            tag.Begin = new MockAttribute(new Constant("1"));
            tag.End   = new MockAttribute(new Constant("6"));
            tag.Step  = new MockAttribute(new Constant("2"));
            tag.Body  = new TemplateAttribute(new Formatter(ComplexBody).Parse().ParsedTemplate);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("[2][4][6]"));
        }
Esempio n. 9
0
        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"));
        }