protected virtual void SetUpCore()
        {
#if SILVERLIGHT
            System.Windows.Browser.HtmlPage.Plugin.Focus();
            workItemTest = new WorkItemTest()
            {
                UnitTestHarness = DevExpress.TestHelper.TestHarness
            };
#endif
        }
        /// <summary>
        /// Repairs focus tests started under a debugger (Visual Studio).
        /// </summary>
        /// <param name="scaffold"></param>
        /// <param name="controlForFocus"></param>
        public static void PrepareFocusFromDebugger(this WorkItemTest scaffold, Control controlForFocus)
        {
            if (Debugger.IsAttached &&
                scaffold.UnitTestHarness.Parameters["tagExpression"].IsNotNullOrEmpty()
                )
            {
                // You have 5 seconds to set the focus from Visual Studio to the testing window.
                // Otherwise a test with the Control.Focus() don't work.
                // + And set a first breakpoint not earlier than the first Assert statement.
                // (Cause: Visual Studio kills the focus in time of a debugging.)
                Debugger.Break();
                scaffold.EnqueueDelay(TimeSpan.FromSeconds(5));
            }

            scaffold.EnqueueCallback(() => controlForFocus.Focus());
        }
Example #3
0
        //TODO: need some way of timing out
        public static void WaitFor <T>(WorkItemTest test, T objectToWaitForItsEvent, string eventName)
        {
            EventInfo eventInfo = objectToWaitForItsEvent.GetType().GetEvent(eventName);

            bool eventRaised = false;

            if (typeof(RoutedEventHandler).IsAssignableFrom(eventInfo.EventHandlerType))
            {
                eventInfo.AddEventHandler(objectToWaitForItsEvent, (RoutedEventHandler) delegate { eventRaised = true; });
            }
            else if (typeof(EventHandler).IsAssignableFrom(eventInfo.EventHandlerType))
            {
                eventInfo.AddEventHandler(objectToWaitForItsEvent, (EventHandler) delegate { eventRaised = true; });
            }

            test.EnqueueConditional(() => eventRaised);
        }
Example #4
0
 public void Init(string description, object content, WorkItemTest test)
 {
     this.textDescription.Text = description;
     this.testContent.Content  = content;
     this.test = test;
 }