Пример #1
0
        public void RethrowInTry()
        {
            TestRethrow  tr   = new TestRethrow();
            TestTryCatch root = new TestTryCatch("parent TryCatch")
            {
                Try = new TestSequence
                {
                    Activities =
                    {
                        new TestProductWriteline("W1"),
                        new TestThrow <TAC.ApplicationException>
                        {
                            ExceptionExpression = (context => new TAC.ApplicationException("abcd")),
                        },
                        tr
                    }
                },
                Catches =
                {
                    new TestCatch <TAC.ApplicationException>
                    {
                        Body = new TestRethrow()
                    }
                },
            };

            TestRuntime.ValidateInstantiationException(root, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName));
        }
Пример #2
0
        public void RethrowOutSideOfTryCatch()
        {
            TestRethrow  tr  = new TestRethrow();
            TestSequence seq = new TestSequence
            {
                Activities =
                {
                    tr,
                    new TestWriteLine

                    {
                        ExpectedOutcome = Outcome.None,
                        Message         = "this should not run",
                        HintMessage     = "nothing"
                    }
                }
            };

            TestRuntime.ValidateInstantiationException(seq, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName));
        }
Пример #3
0
        public void RethrowInFinally()
        {
            TestRethrow  tr   = new TestRethrow();
            TestTryCatch root = new TestTryCatch("parent TryCatch")
            {
                Try = new TestSequence
                {
                    Activities =
                    {
                        new TestProductWriteline("W1"),
                        new TestThrow <TAC.ApplicationException>
                        {
                            ExceptionExpression = (context => new TAC.ApplicationException("abcd")),
                            ExpectedOutcome     = Outcome.CaughtException(typeof(TAC.ApplicationException)),
                        }
                    }
                },
                Catches =
                {
                    new TestCatch <TAC.ApplicationException>()
                },
                Finally = new TestSequence
                {
                    Activities =
                    {
                        new TestSequence
                        {
                            Activities =
                            {
                                tr
                            }
                        }
                    }
                }
            };

            TestRuntime.ValidateInstantiationException(root, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName));
        }