示例#1
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"));
        }
示例#2
0
        public void ChooseTrueAndFalse()
        {
            var tag      = new Choose();
            var whenTrue = new When();

            whenTrue.Body = new MockAttribute(new Property("Body2"));
            whenTrue.Test = new MockAttribute(new Property("True"));
            tag.AddNestedTag(whenTrue);
            var whenFalse = new When();

            whenFalse.Body = new MockAttribute(new Property("Body2"));
            whenFalse.Test = new MockAttribute(new Property("False"));
            tag.AddNestedTag(whenFalse);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(Body2));
        }
示例#3
0
        public void ChooseTrueAndFalse()
        {
            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);
            var whenFalse = new When();

            whenFalse.Body   = new MockAttribute(new Constant("Body2"));
            whenFalse.Select = new MockAttribute(new Constant("/results/value[position()=2]"));
            whenFalse.Source = new MockAttribute(new Constant("xml"));
            tag.AddNestedTag(whenFalse);
            Assert.That(tag.Evaluate(_model), Is.EqualTo("Body1"));
        }
示例#4
0
        public void ChooseOnlyOtherwise()
        {
            var tag       = new Choose();
            var otherwise = new Otherwise();

            otherwise.Body = new MockAttribute(new Property("Body1"));
            tag.AddNestedTag(otherwise);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(Body1));
        }
示例#5
0
        public void ChooseOnlyOtherwise()
        {
            var tag       = new Choose();
            var otherwise = new Otherwise();

            otherwise.Body = new MockAttribute(new Constant("Body1"));
            tag.AddNestedTag(otherwise);
            Assert.That(tag.Evaluate(_model), Is.EqualTo("Body1"));
        }
示例#6
0
        public void ChooseTwoFalseAndOtherWise()
        {
            var tag       = new Choose();
            var whenFalse = new When();

            whenFalse.Body = new MockAttribute(new Property("Body2"));
            whenFalse.Test = new MockAttribute(new Property("False"));
            tag.AddNestedTag(whenFalse);
            var whenFalse2 = new When();

            whenFalse2.Body = new MockAttribute(new Property("Body2"));
            whenFalse2.Test = new MockAttribute(new Property("False"));
            tag.AddNestedTag(whenFalse2);
            var otherwise = new Otherwise();

            otherwise.Body = new MockAttribute(new Property("Body1"));
            tag.AddNestedTag(otherwise);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(Body1));
        }
示例#7
0
        public void ChooseOnlyOneWhenFalse()
        {
            var tag       = new Choose();
            var whenFalse = new When();

            whenFalse.Body = new MockAttribute(new Property("Body2"));
            whenFalse.Test = new MockAttribute(new Property("False"));
            tag.AddNestedTag(whenFalse);
            Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(String.Empty));
        }
示例#8
0
        public void BadTag()
        {
            var tag    = new Choose();
            var outTag = new Out();

            try
            {
                tag.AddNestedTag(outTag);
            }
            catch (TagException Te)
            {
                Assert.AreEqual(Te.Message,
                                TagException.OnlyNestedTagsOfTypeAllowed(typeof(Out), typeof(When), typeof(When)));
            }
        }