public void InHandlerThreadDetectsHandlerThread()
        {
            const string BookmarkName = "Test";

            var activity = new TestBookmark<int> { BookmarkName = BookmarkName };
            var inHandler = false;
            WorkflowApplication workflowApplication = null;
            workflowApplication = new WorkflowApplication(activity)
                {
                    // ReSharper disable AccessToModifiedClosure
                    Idle = args =>
                        {
                            if (workflowApplication != null)
                            {
                                inHandler =
                                    workflowApplication.
                                        IsHandlerThread();

                                // workflowApplication.Cancel();
                                // Doh! Can't to this in a handler
                                // System.InvalidOperationException was unhandled by user code
                                // Message=WorkflowApplication operations cannot be performed from within event handlers.
                            }
                        },

                    // ReSharper restore AccessToModifiedClosure
                };

            workflowApplication.RunEpisode(BookmarkName, Constants.Timeout);

            Assert.IsTrue(inHandler);
            Assert.IsFalse(workflowApplication.IsHandlerThread());
        }