예제 #1
0
        public void TestNoCatchOfException()
        {
            var modelData = new Hashtable();

            modelData.Add("Existing", "Hi");
            modelData.Add("Model", new Hashtable());
            var tag = new Catch();

            tag.Var  = new MockAttribute(new Constant("error"));
            tag.Body = new MockAttribute(new Property("Existing"));
            var model = new TagModel(modelData);

            Assert.That(tag.Evaluate(model), Is.EqualTo("Hi"));
            Assert.That(model["Model.error"], Is.Null);
        }
예제 #2
0
        public void TestCatchOfException()
        {
            var modelData = new Hashtable();

            modelData.Add("Existing", "Hi");
            modelData.Add("Model", new Hashtable());
            var tag = new Catch();

            tag.Var  = new MockAttribute(new Constant("error"));
            tag.Body = new MockAttribute(new Property("Broken.Point"));
            var model = new TagModel(new Broken());

            Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty));
            Assert.That(((ReflectionException)model["Model.error"]).Message,
                        Text.StartsWith(ReflectionException.PropertyNotFound("Broken", typeof(Broken)).Message));
        }
예제 #3
0
        public void TestCatchOfExceptionDifferentPageScope()
        {
            var modelData = new Hashtable();

            modelData.Add("PageScope", VariableScope.Page.ToString());
            modelData.Add("Broken", new Broken());
            modelData.Add("Page", new Hashtable());
            var tag = new Catch();

            tag.Var   = new MockAttribute(new Constant("error"));
            tag.Body  = new MockAttribute(new Property("Broken.Banana"));
            tag.Scope = new MockAttribute(new Property("PageScope"));
            var model = new TagModel(modelData);

            Assert.That(tag.Evaluate(model), Is.EqualTo(String.Empty));
            Assert.That(model["Model.error"], Is.Null);
            Assert.That(((ReflectionException)model["Page.error"]).Message,
                        Text.StartsWith(ReflectionException.PropertyNotFound("Banana", typeof(Broken)).Message));
        }