Example #1
0
        public void SubtractTwoPositiveIntegers()
        {
            TestSubtract <int, int, int> sub = new TestSubtract <int, int, int>(4, 4);

            TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <int, int, int>(sub, "0");

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Example #2
0
        public void ConstraintViolatonInvalidExpression()
        {
            TestSubtract <int, string, string> sub = new TestSubtract <int, string, string>();

            string errorMessage = TestExpressionTracer.GetExceptionMessage <int, string, string>(System.Linq.Expressions.ExpressionType.Subtract);

            TestExpressionTracer.Validate(sub, new List <string> {
                errorMessage
            });
        }
Example #3
0
        public void SubtractTwoIncompatibleTypes()
        {
            TestSubtract <int, string, string> sub = new TestSubtract <int, string, string>
            {
                Left  = 12,
                Right = "12"
            };

            TestRuntime.ValidateInstantiationException(sub, TestExpressionTracer.GetExceptionMessage <int, string, string>(exp.ExpressionType.Subtract));
        }
Example #4
0
        public void LeftOperandNull()
        {
            TestSubtract <int, int, int> sub = new TestSubtract <int, int, int>
            {
                Right = 12
            };

            string errorMessage = string.Format(ErrorStrings.RequiredArgumentValueNotSupplied, "Left");

            TestRuntime.ValidateWorkflowErrors(sub, new List <TestConstraintViolation>(), typeof(ArgumentException), errorMessage);
        }
Example #5
0
        public void CustomTypeOverloadedSubOperatorAsOperands()
        {
            TestSubtract <Complex, Complex, Complex> subComplex = new TestSubtract <Complex, Complex, Complex>
            {
                LeftExpression  = context => new Complex(1, 2),
                RightExpression = context => new Complex(2, 3),
            };

            TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <Complex, Complex, Complex>(subComplex, "-1 -1");

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Example #6
0
        public void SubtractTwoCompatibleDifferentTypes()
        {
            TestSubtract <DateTime, TimeSpan, DateTime> sub = new TestSubtract <DateTime, TimeSpan, DateTime>
            {
                Left  = new DateTime(2009, 2, 12),
                Right = new TimeSpan(17, 58, 59)
            };

            TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity(sub, new DateTime(2009, 2, 11, 06, 01, 01).ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
Example #7
0
        public void CheckedSubOverflow()
        {
            //
            //  Test case description:
            //  subtract two integers which result in overflow of integer. OverflowException is expected.

            TestSubtract <int, int, int> sub = new TestSubtract <int, int, int>()
            {
                Checked             = true,
                Right               = 1,
                Left                = int.MinValue,
                HintExceptionThrown = typeof(OverflowException)
            };

            TestRuntime.RunAndValidateAbortedException(sub, typeof(OverflowException), null);
        }
Example #8
0
        public void ThrowFromOverloadedOperator()
        {
            TestSubtract <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType> sub = new TestSubtract <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType>
            {
                LeftExpression  = context => new OverLoadOperatorThrowingType(13),
                RightExpression = context => new OverLoadOperatorThrowingType(14),
            };

            OverLoadOperatorThrowingType.ThrowException = true;

            sub.ExpectedOutcome = Outcome.UncaughtException();

            TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType>(sub, "12");

            TestRuntime.RunAndValidateAbortedException(seq, typeof(ArithmeticException), null);
        }