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); } }
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"); } }
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) { } }
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); } }
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); } }
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"); } }