/// <summary>
        /// A common helper method that tests running a test in an apartment from an apartment.
        /// </summary>
        private bool RunInApartmentFromApartment(ApartmentState fromApartMent, ApartmentState inApartment)
        {
            bool wasRunInCorrectApartment = false;

            Thread runnerThread = new Thread((ThreadStart) delegate
            {
                if (inApartment == ApartmentState.MTA)
                {
                    ThreadRunner.RunInMTA(delegate
                    {
                        wasRunInCorrectApartment = Thread.CurrentThread.GetApartmentState() == inApartment;
                    });
                }
                else if (inApartment == ApartmentState.STA)
                {
                    ThreadRunner.RunInSTA(delegate
                    {
                        wasRunInCorrectApartment = Thread.CurrentThread.GetApartmentState() == inApartment;
                    });
                }
            }
                                             );

            runnerThread.SetApartmentState(fromApartMent);
            runnerThread.Start();
            runnerThread.Join();

            return(wasRunInCorrectApartment);
        }