Example #1
0
        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);
        }
Example #2
0
        public void DivideByZero()
        {
            TestDivide <int, int, int> divide = new TestDivide <int, int, int>(12, 0)
            {
                ExpectedOutcome = Outcome.UncaughtException()
            };

            TestRuntime.RunAndValidateAbortedException(divide, typeof(DivideByZeroException), null);
        }
Example #3
0
        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
            });
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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));
        }
Example #7
0
        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);
        }