Ejemplo n.º 1
0
        public void ParallelForEachInTryCatchFinally()
        {
            TestTryCatch tcf = new TestTryCatch("TCF")
            {
                Try = new TestParallelForEach <string>("Parallel for each")
                {
                    Body = new TestThrow <InvalidCastException>
                    {
                        ExpectedOutcome = Outcome.CaughtException(typeof(InvalidCastException))
                    },
                    HintValues = new List <string>()
                    {
                        "str1", "STR2", "str3"
                    },
                    ValuesExpression    = (context => new List <string>()
                    {
                        "str1", "STR2", "str3"
                    }),
                    CompletionCondition = true,
                    HintIterationCount  = 1,
                },
                Catches =
                {
                    new TestCatch <InvalidCastException>()
                    {
                        HintHandleException = true
                    }
                }
            };

            ExpectedTrace tr = tcf.GetExpectedTrace();

            TestRuntime.RunAndValidateWorkflow(tcf, tr);
        }
Ejemplo n.º 2
0
        public void ThrowInAction()
        {
            TestPick pick = new TestPick
            {
                DisplayName = "PickActivity",
                Branches    =
                {
                    new TestPickBranch
                    {
                        DisplayName = "Triggered",
                        Trigger     = new TestWriteLine("Trigger1")
                        {
                            Message = "Trigger1",
                        },

                        Action = new TestThrow <ApplicationException>("ThrowInAction")
                        {
                            ExceptionExpression = (context => new ApplicationException("Fault in trigger")),
                            ExpectedOutcome     = Outcome.CaughtException(typeof(ApplicationException)),
                        }
                    },

                    new TestPickBranch
                    {
                        DisplayName     = "NoTriggered",
                        ExpectedOutcome = Outcome.Canceled,

                        Trigger = new TestWriteLine("Trigger2")
                        {
                            Message         = "Trigger2",
                            ExpectedOutcome = Outcome.Completed,
                        },

                        Action = new TestWriteLine("Action2")
                        {
                            Message = "Action2"
                        }
                    }
                }
            };

            TestTryCatch testTCF = new TestTryCatch
            {
                DisplayName = "TryCatch",
                Try         = pick,
                Catches     =
                {
                    new TestCatch <ApplicationException>()
                    {
                        Body = new TestWriteLine("CatchWriteLine")
                        {
                            Message = "Caught",
                        }
                    }
                }
            };

            ExpectedTrace trace = testTCF.GetExpectedTrace();

            TestRuntime.RunAndValidateWorkflow(testTCF, trace);
        }