예제 #1
0
        public void InheritedExceptions1()
        {
            // exception which is raised
            Exception exc = new Exception();

            // try
            TestSequence trySeq = new TestSequence();

            trySeq.Activities.Add(new TestWriteLine("Try", "Try"));
            TestThrow <Exception> tt = new TestThrow <Exception>("TestThrow1")
            {
                ExceptionExpression = (context => new Exception())
            };

            trySeq.Activities.Add(tt);

            // catch
            TestCatch[] catches = new TestCatch[] { new TestCatch <ArgumentException>() };

            // create and run
            TestActivity act = CreateTryCatchFinally(trySeq, catches, null, WFType.SEQ, true);

            TestRuntime.RunAndValidateAbortedException(act, exc.GetType(),
                                                       new Dictionary <string, string> {
                { "Message", exc.Message }
            });
        }
예제 #2
0
        public void ThrowExceptionInElseBody()
        {
            //  Test case description:
            //  2 bracnhes:throw exception in the condition throw exception in if body, else executingthrow exception
            //  in else body if executingthrow exception in both branches if executingthrow exception in both branches
            //  else executing

            TestSequence   outerSequence = new TestSequence("sequence1");
            TestSequence   innerSequence = new TestSequence("inner seq");
            Variable <int> counter       = VariableHelper.CreateInitialized <int>("counter", 0);

            TestWriteLine writeLine = new TestWriteLine("write hello")
            {
                Message = "Its a small world after all"
            };

            TestIf ifAct = new TestIf("if act", HintThenOrElse.Else)
            {
                ConditionExpression = ((env) => ((int)counter.Get(env)) > 10),
                ThenActivity        = new TestSequence("sequence in if"),
                ElseActivity        = innerSequence
            };

            TestThrow <ArithmeticException> throwArt = new TestThrow <ArithmeticException>("throw");

            innerSequence.Activities.Add(throwArt);
            outerSequence.Activities.Add(ifAct);
            innerSequence.Activities.Add(writeLine);
            outerSequence.Variables.Add(counter);

            TestRuntime.RunAndValidateAbortedException(outerSequence, typeof(ArithmeticException), new Dictionary <string, string>());
        }
예제 #3
0
        public void FaultWhileExecutingInLoop()
        {
            TestFlowchart flowchart = new TestFlowchart();

            Variable <int> counter = VariableHelper.CreateInitialized <int>(-3);

            counter.Name = "counter";
            flowchart.Variables.Add(counter);

            List <HintTrueFalse> hints = new List <HintTrueFalse> {
                HintTrueFalse.True, HintTrueFalse.True, HintTrueFalse.Exception
            };
            TestFlowConditional conditional = new TestFlowConditional(hints.ToArray())
            {
                ConditionExpression = env => (counter.Get(env) - 1) / counter.Get(env) > 0
            };

            TestIncrement decByOne = new TestIncrement {
                CounterVariable = counter, IncrementCount = 1
            };

            flowchart.AddLink(new TestWriteLine("Start", "Start"), decByOne);

            flowchart.AddConditionalLink(decByOne, conditional, decByOne, null);

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(DivideByZeroException), null);
        }
예제 #4
0
        public void TryCatchFinallyWithExceptionInCatchingCatch()
        {
            TestTryCatch tryCatch = new TestTryCatch("TryCatchTest")
            {
                Try = new TestSequence("TrySeq")
                {
                    Activities =
                    {
                        new TestThrow <ArgumentException>("TryException")
                        {
                            ExpectedOutcome = Outcome.CaughtException()
                        },
                    },
                },

                Catches =
                {
                    new TestCatch <ArgumentException>()
                    {
                        Body = new TestThrow <ArithmeticException>("Throw from catch")
                        {
                            ExceptionExpression = (context => new ArithmeticException())
                        }
                    },
                },
                Finally = new TestWriteLine("Finally", "Finally")
            };

            // Run test
            TestRuntime.RunAndValidateAbortedException(tryCatch, typeof(ArithmeticException), null);
        }
예제 #5
0
        public void ThrowFromNode()
        {
            TestFlowchart  flowchart  = new TestFlowchart();
            Variable <int> expression = new Variable <int> {
                Name = "expression", Default = 3
            };

            flowchart.Variables.Add(expression);

            TestWriteLine         w1       = new TestWriteLine("One", "One wont execute");
            TestWriteLine         w2       = new TestWriteLine("Two", "Two will execute");
            TestThrow <Exception> throwAct = new TestThrow <Exception>();

            Dictionary <int, TestActivity> cases = new Dictionary <int, TestActivity>();

            cases.Add(1, w1);
            cases.Add(2, w2);
            cases.Add(3, throwAct);

            List <int> hints = new List <int>();

            hints.Add(2);
            flowchart.AddSwitchLink <int>(new TestWriteLine("Start", "Flowchart started"), cases, hints, expression, new TestWriteLine("Default", "Default"));

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(Exception), null);
        }
예제 #6
0
        public void TryAccessingItemFromAnUninitializedArray()
        {
            Variable <int[]> intArrayVar = new Variable <int[]>()
            {
                Name = "IntVar"
            };

            TestArrayItemValue <int> arrayVal = new TestArrayItemValue <int>
            {
                DisplayName     = "GetValue",
                ArrayVariable   = intArrayVar,
                Index           = 4,
                ExpectedOutcome = Outcome.UncaughtException()
            };

            TestSequence seq = new TestSequence
            {
                Variables  = { intArrayVar },
                Activities =
                {
                    arrayVal
                }
            };

            TestRuntime.RunAndValidateAbortedException(
                seq,
                typeof(InvalidOperationException),
                new Dictionary <string, string>
            {
                { "Message", string.Format(ErrorStrings.MemberCannotBeNull, "Array", arrayVal.ProductActivity.GetType().Name, arrayVal.DisplayName) }
            });
        }
예제 #7
0
        public void ThrowCatchRethrow()
        {
            TestTryCatch ttc = new TestTryCatch("parent TryCatch")
            {
                Try = new TestSequence
                {
                    Activities =
                    {
                        new TestProductWriteline("W1"),
                        new TestThrow <TAC.ApplicationException>
                        {
                            ExceptionExpression = (context => new TAC.ApplicationException("this is expected uncaught exception")),
                            ExpectedOutcome     = Outcome.CaughtException(typeof(TAC.ApplicationException)),
                        }
                    }
                },
                Catches =
                {
                    new TestCatch <TAC.ApplicationException>
                    {
                        Body = new TestRethrow
                        {
                            ExpectedOutcome = Outcome.UncaughtException(typeof(TAC.ApplicationException)),
                        }
                    }
                }
            };
            Dictionary <string, string> exceptionProperties = new Dictionary <string, string>();

            TestRuntime.RunAndValidateAbortedException(ttc, typeof(TAC.ApplicationException), exceptionProperties);
        }
예제 #8
0
        public void ThrowWhileEvaluatingExpression()
        {
            TestFlowchart flowchart = new TestFlowchart();

            TestWriteLine writeHello = new TestWriteLine("Hello", "Hello");

            TestWriteLine writeStart = new TestWriteLine("Start", "Start");

            TestExpressionEvaluatorWithBody <string> expressionActivity = new TestExpressionEvaluatorWithBody <string>("One")
            {
                Body = new TestThrow <ArgumentOutOfRangeException>()
            };

            Dictionary <string, TestActivity> cases = new Dictionary <string, TestActivity>();

            cases.Add("One", new TestWriteLine("One", "One will not execute"));
            cases.Add("Two", new TestWriteLine("Two", "Two will not execute"));

            List <int> hints = new List <int>()
            {
                -1
            };

            flowchart.AddStartLink(writeStart);

            flowchart.AddSwitchLink <string>(writeStart, cases, hints, expressionActivity, new TestWriteLine("Default", "Will not execute"));

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(ArgumentOutOfRangeException), null);
        }
예제 #9
0
        public void ThrowActivityInInnerMostLoop()
        {
            List <string> values = new List <string>()
            {
                "HI", "THere"
            };
            TestSequence seq = new TestSequence()
            {
                Activities =
                {
                    new TestForEach <string>()
                    {
                        Values = values,
                        Body   = new TestForEach <string>
                        {
                            Values = values,
                            Body   = new TestForEach <string>
                            {
                                Values = values,
                                Body   = new TestForEach <string>()
                                {
                                    Values = values,
                                    Body   = new TestThrow <TestCaseException>()
                                }
                            }
                        }
                    }
                }
            };

            TestRuntime.RunAndValidateAbortedException(seq, typeof(TestCaseException), new Dictionary <string, string>());
        }
예제 #10
0
        public void ConditionExpressionDivideByZero()
        {
            Variable <int> counter1 = VariableHelper.CreateInitialized <int>("counter1", 0);
            Variable <int> counter2 = VariableHelper.CreateInitialized <int>("counter2", 2);

            TestFlowchart flowchart = new TestFlowchart("Flowchart")
            {
                Variables =
                {
                    counter1,
                    counter2
                },
                ExpectedOutcome = Outcome.UncaughtException(typeof(DivideByZeroException))
            };

            flowchart.ExpectedOutcome.IsOverrideable = true;

            TestAssign <int> assign = new TestAssign <int>("Assign")
            {
                ValueExpression = ((env) => (counter1.Get(env) + 1)),
                ToExpression    = ((env) => counter2.Get(env))
            };

            TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.Exception)
            {
                ConditionExpression = ((env) => counter1.Get(env) / (counter2.Get(env) - 1) >= 0),
            };

            flowchart.AddLink(new TestWriteLine("Start", "Flowchart Started"), assign);
            flowchart.AddConditionalLink(assign, flowDecision, assign, (TestActivity)null);

            TestRuntime.RunAndValidateAbortedException(flowchart, typeof(DivideByZeroException), null);
        }
예제 #11
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);
        }
예제 #12
0
        public void ThrowCustomException()
        {
            TestThrow <CustomException> th = new TestThrow <CustomException>("custom exception")
            {
                ExceptionExpression = (context => new CustomException("Invalid department"))
            };

            TestRuntime.RunAndValidateAbortedException(th, typeof(CustomException), new Dictionary <string, string>());
        }
예제 #13
0
        public void ThrowExceptionFromGetterOFCustomTypeProperty()
        {
            TestPropertyValue <ExceptionThrowingSetterAndGetter, int> propertyValue = new TestPropertyValue <ExceptionThrowingSetterAndGetter, int>
            {
                OperandExpression = context => new ExceptionThrowingSetterAndGetter(),
                PropertyName      = "ExceptionThrowingProperty",
                ExpectedOutcome   = Outcome.UncaughtException()
            };

            TestRuntime.RunAndValidateAbortedException(propertyValue, typeof(IndexOutOfRangeException), null);
        }
예제 #14
0
        public void ThrowWithExceptionSet()
        {
            //TestParameters.DisableXamlRoundTrip = true;
            DelegateInArgument <ArgumentNullException> ex = new DelegateInArgument <ArgumentNullException>();
            TestSequence seq = new TestSequence("Seq")
            {
                Activities =
                {
                    new TestTryCatch("Try catch finally")
                    {
                        Try = new TestSequence("Try")
                        {
                            Activities =
                            {
                                new TestThrow <ArgumentNullException>()
                                {
                                    ExpectedOutcome     = new CaughtExceptionOutcome(typeof(ArgumentNullException)),
                                    ExceptionExpression = (context => new ArgumentNullException("Value cannot be null.", new InvalidCastException())),
                                }
                            }
                        },

                        Catches =
                        {
                            new TestCatch <InvalidCastException>()
                            {
                            },
                            new TestCatch <ArgumentNullException>
                            {
                                ExceptionVariable = ex,
                                Body = new TestSequence()
                                {
                                    Activities =
                                    {
                                        new TestWriteLine()
                                        {
                                            HintMessage       = "Value cannot be null.",
                                            MessageExpression = (env) => (string)ex.Get(env).Message,
                                        },

                                        new TestThrow <InvalidCastException>()
                                        {
                                            ExceptionExpression = (env) => (InvalidCastException)ex.Get(env).InnerException,
                                        }
                                    }
                                },
                            }
                        }
                    }
                }
            };

            TestRuntime.RunAndValidateAbortedException(seq, typeof(InvalidCastException), new Dictionary <string, string>());
        }
예제 #15
0
        //This is disabled in desktop and failing too.
        //[Fact]
        public void ThrowWhileEvaluatingLeft()
        {
            TestAnd <bool, bool, bool> and = new TestAnd <bool, bool, bool>
            {
                LeftActivity = new TestExpressionEvaluatorWithBody <bool>
                {
                    Body = new TestThrow <ArithmeticException>()
                },
                Right = true
            };

            TestRuntime.RunAndValidateAbortedException(and, typeof(ArithmeticException), null);
        }
예제 #16
0
        public void ThrowInNestedTryCatchRethrowInTheTopTryCatch()
        {
            TestTryCatch root = new TestTryCatch("parentTryCatch");

            root.Catches.Add(
                new TestCatch <TAC.ApplicationException>
            {
                Body = new TestRethrow
                {
                    ExpectedOutcome = Outcome.UncaughtException(typeof(TAC.ApplicationException)),
                }
            });

            TestTryCatch level1 = new TestTryCatch("level1");

            level1.Catches.Add(new TestCatch <ArithmeticException> {
                Body = new TestProductWriteline("don't write this 1")
            });
            root.Try = level1;

            TestTryCatch level2 = new TestTryCatch("level2");

            level2.Catches.Add(new TestCatch <ArithmeticException> {
                Body = new TestProductWriteline("don't write this 2")
            });
            level1.Try = level2;

            TestTryCatch level3 = new TestTryCatch("level3");

            level3.Catches.Add(new TestCatch <ArithmeticException> {
                Body = new TestProductWriteline("don't write this 3")
            });
            level2.Try = level3;

            level3.Try = new TestSequence
            {
                Activities =
                {
                    new TestProductWriteline("W1"),
                    new TestThrow <TAC.ApplicationException>
                    {
                        ExceptionExpression = (context => new TAC.ApplicationException("this is expected uncaught exception")),
                        ExpectedOutcome     = Outcome.CaughtException(typeof(TAC.ApplicationException)),
                    }
                }
            };

            Dictionary <string, string> exceptionProperties = new Dictionary <string, string>();

            TestRuntime.RunAndValidateAbortedException(root, typeof(TAC.ApplicationException), exceptionProperties);
        }
예제 #17
0
        public void ThrowExceptionInValues()
        {
            UnorderedTraces ordered = new UnorderedTraces()
            {
                Steps =
                {
                    new OrderedTraces()
                    {
                        Steps =
                        {
                            new ActivityTrace("w1", ActivityInstanceState.Executing),
                            new ActivityTrace("w1", ActivityInstanceState.Faulted),
                        }
                    },
                    new OrderedTraces()
                    {
                        Steps =
                        {
                            new ActivityTrace("w1", ActivityInstanceState.Executing),
                            new ActivityTrace("w1", ActivityInstanceState.Faulted),
                        }
                    },
                    new OrderedTraces()
                    {
                        Steps =
                        {
                            new ActivityTrace("w1", ActivityInstanceState.Executing),
                            new ActivityTrace("w1", ActivityInstanceState.Faulted),
                        }
                    }
                }
            };

            TestParallelForEach <int> foreachAct = new TestParallelForEach <int>("foreach")
            {
                ValuesExpression = context => new IEnumerableWithException {
                    NumberOfIterations = 3
                },
                Body = new TestWriteLine("w1")
                {
                    Message = "w1"
                },
                ExpectedOutcome        = Outcome.Faulted,
                ActivitySpecificTraces =
                {
                    ordered,
                }
            };

            TestRuntime.RunAndValidateAbortedException(foreachAct, typeof(TestCaseException), new Dictionary <string, string>());
        }
예제 #18
0
        public void ThrowFromOverloadedOperator()
        {
            TestAnd <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType> testAnd = new TestAnd <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, OverLoadOperatorThrowingType>();

            testAnd.ProductAnd.Left  = new InArgument <OverLoadOperatorThrowingType>(context => new OverLoadOperatorThrowingType(13));
            testAnd.ProductAnd.Right = new InArgument <OverLoadOperatorThrowingType>(context => new OverLoadOperatorThrowingType(14));
            OverLoadOperatorThrowingType.ThrowException = true;

            testAnd.ExpectedOutcome = Outcome.UncaughtException();

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

            TestRuntime.RunAndValidateAbortedException(seq, typeof(DivideByZeroException), null);
        }
예제 #19
0
        /// <summary>
        /// Throw exception in left activity.
        /// </summary>
        /// This is disabled in desktop and failing too.
        //[Fact]
        private void ThrowExceptionWhileEvaluatingLeft()
        {
            TestAndAlso andAlso = new TestAndAlso
            {
                LeftActivity = new TestExpressionEvaluatorWithBody <bool>
                {
                    Body = new TestThrow <ArithmeticException>()
                },
                Right           = false,
                ExceptionInLeft = true
            };

            TestRuntime.RunAndValidateAbortedException(andAlso, typeof(ArithmeticException), null);
        }
예제 #20
0
        public void ThrowExceptionInCase()
        {
            TestSwitch <float> switchAct = new TestSwitch <float>();

            switchAct.DisplayName = "Switch Act";
            switchAct.AddCase(123, new TestThrow <InvalidCastException>("THrow invalid cast")
            {
                ExpectedOutcome = Outcome.UncaughtException(typeof(InvalidCastException))
            });
            switchAct.Expression = 123;
            switchAct.Hints.Add(0);

            TestRuntime.RunAndValidateAbortedException(switchAct, typeof(InvalidCastException), new Dictionary <string, string>());
        }
예제 #21
0
        public void ThrowWithInnerException()
        {
            // Initializing variable which we will use to catch the exception object
            DelegateInArgument <MemberAccessException> accExc = new DelegateInArgument <MemberAccessException>();
            //TestParameters.DisableXamlRoundTrip = true;
            TestSequence seq = new TestSequence("Outer Seq")
            {
                Activities =
                {
                    new TestTryCatch("Try catch finally")
                    {
                        Try = new TestSequence("Try Activity")
                        {
                            Activities =
                            {
                                new TestThrow <MemberAccessException>("Throw Operation exception")
                                {
                                    ExceptionExpression = (context => new MemberAccessException("Throw Exception", new IndexOutOfRangeException())),
                                    //InnerException = new IndexOutOfRangeException(),
                                    ExpectedOutcome = Outcome.CaughtException(),
                                }
                            }
                        },

                        Catches =
                        {
                            new TestCatch <MemberAccessException>()
                            {
                                ExceptionVariable = accExc,
                                Body = new TestSequence("Body of Catch")
                                {
                                    Activities =
                                    {
                                        // Rethrowing inner exception so we can verify correct exception is thrown
                                        new TestThrow <IndexOutOfRangeException>("Throw inner exception")
                                        {
                                            ExceptionExpression = (env) => (IndexOutOfRangeException)accExc.Get(env).InnerException,
                                            ExpectedOutcome     = Outcome.UncaughtException(typeof(IndexOutOfRangeException))
                                        }
                                    }
                                },
                            }
                        }
                    }
                }
            };

            TestRuntime.RunAndValidateAbortedException(seq, typeof(IndexOutOfRangeException), new Dictionary <string, string>());
        }
예제 #22
0
        public void ThrowFromOverloadedOperator()
        {
            TestNot <OverLoadOperatorThrowingType, bool> not = new TestNot <OverLoadOperatorThrowingType, bool>
            {
                OperandExpression = context => new OverLoadOperatorThrowingType(13)
            };

            OverLoadOperatorThrowingType.ThrowException = true;

            not.ExpectedOutcome = Outcome.UncaughtException();

            TestSequence seq = TestExpressionTracer.GetTraceableUnaryExpressionActivity <OverLoadOperatorThrowingType, bool>(not, "12");

            TestRuntime.RunAndValidateAbortedException(seq, typeof(ArithmeticException), null);
        }
예제 #23
0
        public void ThrowFromOverloadedOperator()
        {
            TestGreaterThan <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, bool> greaterThan = new TestGreaterThan <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, bool>
            {
                LeftExpression  = context => new OverLoadOperatorThrowingType(2),
                RightExpression = context => new OverLoadOperatorThrowingType(1),
                ExpectedOutcome = Outcome.UncaughtException()
            };

            OverLoadOperatorThrowingType.ThrowException = true;

            TestSequence seq = TestExpressionTracer.GetTraceableBinaryExpressionActivity <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, bool>(greaterThan, true.ToString());

            TestRuntime.RunAndValidateAbortedException(seq, typeof(ArithmeticException), null);
        }
예제 #24
0
        public void CheckedCastOverflow()
        {
            //
            //  Test case description:
            //  Cast long to short which result in overflow of integer. OverflowException is expected.

            TestCast <long, short> cast = new TestCast <long, short>()
            {
                Checked             = true,
                Operand             = short.MaxValue + 1L,
                HintExceptionThrown = typeof(OverflowException)
            };

            TestRuntime.RunAndValidateAbortedException(cast, typeof(OverflowException), null);
        }
예제 #25
0
        public void CheckedAddOverflow()
        {
            //
            //  Test case description:
            //  add two integers which result in overflow of integer. OverflowException is expected.

            TestAdd <int, int, int> add = new TestAdd <int, int, int>()
            {
                Checked             = true,
                Right               = int.MaxValue,
                Left                = 1,
                HintExceptionThrown = typeof(OverflowException)
            };

            TestRuntime.RunAndValidateAbortedException(add, typeof(OverflowException), null);
        }
예제 #26
0
파일: Or.cs 프로젝트: sunxiaotianmg/CoreWF
        public void ThrowFromOverloadedOperator()
        {
            TestOr <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, int> or = new TestOr <OverLoadOperatorThrowingType, OverLoadOperatorThrowingType, int>
            {
                LeftExpression  = context => new OverLoadOperatorThrowingType(13),
                RightExpression = context => new OverLoadOperatorThrowingType(14),
            };

            OverLoadOperatorThrowingType.ThrowException = true;

            or.ExpectedOutcome = Outcome.UncaughtException();

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

            TestRuntime.RunAndValidateAbortedException(seq, typeof(ArithmeticException), null);
        }
예제 #27
0
파일: Subtract.cs 프로젝트: jbzorg/corewf
        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);
        }
예제 #28
0
        public void ThrowExceptionInExpression()
        {
            TestSwitch <int> switchAct = new TestSwitch <int>();
            Variable <int>   temp      = VariableHelper.CreateInitialized <int>("temp", 3);
            TestSequence     seq       = new TestSequence();

            seq.Activities.Add(switchAct);
            seq.Variables.Add(temp);

            switchAct.AddCase(123, new TestSequence("Seq"));
            switchAct.ExpressionExpression = (env) => (int)(1 / (temp.Get(env) - 3));
            switchAct.Hints.Add(-1);
            switchAct.ExpectedOutcome = Outcome.UncaughtException(typeof(DivideByZeroException));

            TestRuntime.RunAndValidateAbortedException(seq, typeof(DivideByZeroException), new Dictionary <string, string>());
        }
예제 #29
0
        public void SwitchThrowInDefault()
        {
            TestSwitch <float> switchAct = new TestSwitch <float>();

            switchAct.AddCase(123, new TestThrow <InvalidCastException>("Throw invalid cast")
            {
                ExpectedOutcome = Outcome.None
            });
            switchAct.Default = new TestThrow <TestCaseException>("Op cancelled")
            {
                ExpectedOutcome = Outcome.UncaughtException(typeof(TestCaseException))
            };
            switchAct.Expression = 456;
            switchAct.Hints.Add(-1);
            TestRuntime.RunAndValidateAbortedException(switchAct, typeof(TestCaseException), new Dictionary <string, string>());
        }
예제 #30
0
        public void TryCatchFinallyWithExceptionInFinally()
        {
            // Uncaught Exception
            ArithmeticException exc = new ArithmeticException();

            // finally
            TestThrow <ArithmeticException> tt = new TestThrow <ArithmeticException>("Test Throw")
            {
                ExceptionExpression = (context => new ArithmeticException())
            };

            // Run test
            TestActivity act = CreateTryCatchFinally(null, null, tt, WFType.SEQ, false);

            TestRuntime.RunAndValidateAbortedException(act, exc.GetType(), null);
        }