public void DivideTwoPositiveIntegers() { TestDivide <int, int, int> divide = new TestDivide <int, int, int>(12, 4); TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <int, int, int>(divide, "3"); TestRuntime.RunAndValidateWorkflow(seq); }
public void DivideByZero() { TestDivide <int, int, int> divide = new TestDivide <int, int, int>(12, 0) { ExpectedOutcome = Outcome.UncaughtException() }; TestRuntime.RunAndValidateAbortedException(divide, typeof(DivideByZeroException), null); }
public void ConstraintViolatonInvalidExpression() { TestDivide <int, string, string> div = new TestDivide <int, string, string>(); string errorMessage = TestExpressionTracer.GetExceptionMessage <int, string, string>(System.Linq.Expressions.ExpressionType.Divide); TestExpressionTracer.Validate(div, new List <string> { errorMessage }); }
public void RightOperandNull() { TestDivide <int, int, int> div = new TestDivide <int, int, int> { Left = 12 }; string errorMessage = string.Format(ErrorStrings.RequiredArgumentValueNotSupplied, "Right"); TestRuntime.ValidateWorkflowErrors(div, new List <TestConstraintViolation>(), typeof(ArgumentException), errorMessage); }
public void CustomTypeOverloadedDivideOperatorAsOperands() { TestDivide <Complex, Complex, Complex> divide = new TestDivide <Complex, Complex, Complex> { LeftExpression = context => new Complex(2, 6), RightExpression = context => new Complex(1, 2), }; TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <Complex, Complex, Complex>(divide, "2 3"); TestRuntime.RunAndValidateWorkflow(seq); }
public void SubtractTwoIncompatibleTypes() { TestDivide <int, double, double> divide = new TestDivide <int, double, double>(4, 4.2); TestRuntime.ValidateInstantiationException(divide, TestExpressionTracer.GetExceptionMessage <int, double, double>(System.Linq.Expressions.ExpressionType.Divide)); }
public void ThrowFromOverloadedOperator() { TestDivide <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType> div = new TestDivide <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType> { LeftExpression = context => new OverLoadOperatorThrowingType(13), RightExpression = context => new OverLoadOperatorThrowingType(14), }; OverLoadOperatorThrowingType.ThrowException = true; div.ExpectedOutcome = Outcome.UncaughtException(); TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType>(div, "12"); TestRuntime.RunAndValidateAbortedException(seq, typeof(ArithmeticException), null); }