コード例 #1
0
        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)
            {

            }            
        }
コード例 #2
0
 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);
     }
 }
コード例 #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");
            }
        }
コード例 #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)
            {
            }
        }
コード例 #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);
            }
        }
コード例 #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);
     }
 }
コード例 #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);
            }
        }
コード例 #8
0
 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");
     }   
 }