private static void workflowCompletedNoExceptions(object sender, TestWorkflowCompletedEventArgs e)
 {
     if (e.EventArgs.TerminationException != null)
     {
         throw new TestCaseFailedException("Workflow was not terminated by TerminateWorkflow, Exception should not exist.");
     }
 }
        private static void workflowInstance_Completed(object sender, TestWorkflowCompletedEventArgs e)
        {
            Exception innerException = e.EventArgs.TerminationException.InnerException;

            // Checking for Inner Exception
            if (innerException != null)
            {
                if (innerException.GetType() != s_exceptionType)
                {
                    throw new TestCaseFailedException("Exception is Incorrect");
                }

                string exceptionMessage = innerException.Message;
                if (!exceptionMessage.Equals(s_exceptionMsg))
                {
                    throw new TestCaseFailedException("Exception Message is Incorrect");
                }
            }

            // Checking for Reason
            string reason = e.EventArgs.TerminationException.Message;

            if (!reason.Equals(s_terminationReason))
            {
                throw new TestCaseFailedException("Reason Message is Incorrect");
            }
        }
        private static void VerifyUnsetValue(object sender, TestWorkflowCompletedEventArgs e)
        {
            Exception terminationException = e.EventArgs.TerminationException;
            string    reason = terminationException.Message;

            // Exception Not Set & Reason Set - We Expect:
            // 1. TerminationException = WorkflowTerminatedException
            // 2. TerminationException.InnerException = null
            // 3. TerminationException.Message = TerminationReason.
            if ((s_exceptionType == null) && (s_exceptionMsg == null))
            {
                if (terminationException.GetType() != typeof(WorkflowTerminatedException))
                {
                    throw new TestCaseFailedException("Reason is not set, TerminationException should match ExceptionType");
                }
                if (!terminationException.Message.Equals(s_terminationReason))
                {
                    throw new TestCaseFailedException("Exception is not set, InnerException should be null!");
                }
            }
            // Exception Set & Reason Not Set - We Expect:
            // 1. TerminationException = ExceptionType
            // 2. TerminationException.InnerException = null
            // 3. TerminationException.Message = ExceptionMsg.
            else if (s_terminationReason == null)
            {
                if (terminationException.GetType() != s_exceptionType)
                {
                    throw new TestCaseFailedException("Reason is not set, TerminationException should match ExceptionType");
                }
                if (terminationException.InnerException != null)
                {
                    throw new TestCaseFailedException("Reason is not set, InnerException should be null!");
                }
                if (!reason.Equals(s_exceptionMsg))
                {
                    throw new TestCaseFailedException("Reason is not set, Message should match ExceptionType's Message!");
                }
            }
        }