public void WhenInvalidThrowDefaultException()
        {
            Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            Dictionary<string, object> vars = new Dictionary<string, object>();
            ExceptionAction action = new ExceptionAction();
            try
            {
                action.Execute(false, context, vars, null);
                Assert.Fail("Should have thrown exception");
            }
            catch (ValidationException)
            {

            }            
        }
 public void WhenInvalidThrowCustomException()
 {
     Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
     Dictionary<string, object> vars = new Dictionary<string, object>();
     ExceptionAction action = new ExceptionAction("new System.InvalidOperationException('invalid')");
     try
     {
         action.Execute(false, context, vars, null);
         Assert.Fail("Should have thrown exception");
     }
     catch (InvalidOperationException e)
     {
         Assert.AreEqual("invalid", e.Message);
     }
 }
Esempio n. 3
0
        public void WhenValid()
        {
            Inventor        context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            IDictionary     vars    = new Hashtable();
            ExceptionAction action  = new ExceptionAction();

            try
            {
                action.Execute(true, context, vars, null);
            }
            catch (Exception)
            {
                Assert.Fail("Should not have thrown exception");
            }
        }
Esempio n. 4
0
        public void WhenInvalidThrowDefaultException()
        {
            Inventor        context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            IDictionary     vars    = new Hashtable();
            ExceptionAction action  = new ExceptionAction();

            try
            {
                action.Execute(false, context, vars, null);
                Assert.Fail("Should have thrown exception");
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 5
0
        public void WhenInvalidThrowCustomException()
        {
            Inventor        context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            IDictionary     vars    = new Hashtable();
            ExceptionAction action  = new ExceptionAction("new System.InvalidOperationException('invalid')");

            try
            {
                action.Execute(false, context, vars, null);
                Assert.Fail("Should have thrown exception");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual("invalid", e.Message);
            }
        }
Esempio n. 6
0
 public void WhenInvalidThrowCustomExceptionUsingSetter()
 {
     Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
     IDictionary vars = new Hashtable();
     ExceptionAction action = new ExceptionAction();
     IExpression expression = Expression.Parse("new System.InvalidOperationException('invalid')");
     action.ThrowsExpression = expression;
     try
     {
         action.Execute(false, context, vars, null);
         Assert.Fail("Should have thrown exception");
     }
     catch (InvalidOperationException e)
     {
         Assert.AreEqual("invalid", e.Message);
     }
 }
Esempio n. 7
0
        public void WhenInvalidThrowCustomExceptionUsingSetter()
        {
            Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
            Dictionary <string, object> vars   = new Dictionary <string, object>();
            ExceptionAction             action = new ExceptionAction();
            IExpression expression             = Expression.Parse("new System.InvalidOperationException('invalid')");

            action.ThrowsExpression = expression;
            try
            {
                action.Execute(false, context, vars, null);
                Assert.Fail("Should have thrown exception");
            }
            catch (InvalidOperationException e)
            {
                Assert.AreEqual("invalid", e.Message);
            }
        }
 public void WhenValid()
 {
     Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
     Dictionary<string, object> vars = new Dictionary<string, object>();
     ExceptionAction action = new ExceptionAction();
     try
     {
         action.Execute(true, context, vars, null);                
     }
     catch (Exception)
     {
         Assert.Fail("Should not have thrown exception");
     }   
 }