Esempio n. 1
0
        public void TestWorkflowApplicationWithoutOnUnhandledException()
        {
            AutoResetEvent syncEvent = new AutoResetEvent(false);
            var            a         = new ThrowSomething();

            var  app       = new WorkflowApplication(a);
            bool aborted   = false;
            bool completed = false;


            app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                completed = true;
                syncEvent.Set();
            };

            app.Aborted = (eventArgs) =>
            {
                aborted = true;
                syncEvent.Set();
            };
            app.Run();
            syncEvent.WaitOne();
            Assert.True(completed);
            Assert.False(aborted);
        }
Esempio n. 2
0
        public void TestWorkflowApplicationCatchException()
        {
            AutoResetEvent syncEvent = new AutoResetEvent(false);
            var            a         = new ThrowSomething();

            var  app = new WorkflowApplication(a);
            bool exceptionHandled = false;
            bool aborted          = false;
            int  mainThreadId     = Thread.CurrentThread.ManagedThreadId;
            int  workFlowThreadId = -1;

            app.OnUnhandledException = (e) =>
            {
                Assert.IsType <NotImplementedException>(e.UnhandledException);
                exceptionHandled = true;
                workFlowThreadId = Thread.CurrentThread.ManagedThreadId;
                return(UnhandledExceptionAction.Abort);
            };

            app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                Assert.True(false, "Never completed");
                syncEvent.Set();
            };

            app.Aborted = (eventArgs) =>
            {
                aborted = true;
                syncEvent.Set();
            };
            app.Run();
            syncEvent.WaitOne();
            Assert.True(exceptionHandled);
            Assert.True(aborted);
            Assert.NotEqual(mainThreadId, workFlowThreadId);
        }