Пример #1
0
        protected override void OnStartup(EventArgs e)
        {
            base.OnStartup(e);

            var dispatch = new FeedbackDispatcher();

            //NB: we must wait and create all UI objects in 'OnStartup' so they are on the dispatcher thread
            TestRunView gui = new TestRunView();

            MainWindow.Child = gui;

            dispatch.Add(gui);
            dispatch.Add(new FeedbackToDebug());
            if (BuildAutomation.InBuild)
            {
                dispatch.Add(new FeedbackToLogFiles());
            }
            else if (_logDirectory != null)
            {
                dispatch.Add(new FeedbackToLogFiles(_logDirectory));
            }

            // connect input scroll buttons
            if (_input != null)
            {
                if (_input.ScrollUp != null)
                {
                    _input.ScrollUp.OnInterrupt += (source, state, time) => {
                        Debug.Print("Scroll Up Requested");
                        gui.ScrollUp();
                    };
                }
                if (_input.ScrollDown != null)
                {
                    _input.ScrollDown.OnInterrupt += (source, state, time) => {
                        Debug.Print("Scroll Down Requested");
                        gui.ScrollDown();
                    };
                }
            }

            var runner = new TestRunner(_assembly, _input, dispatch);

            if (BuildAutomation.InBuild)
            {
                runner.ExecuteTests()
                .ContinueWith(previous => Dispatcher.BeginInvoke(StartShutdown, null));
            }
            else
            {
                runner.ExecuteTests();
            }
        }
Пример #2
0
        public static void RunTests(Assembly assembly,
                                    IRunnerUserInput input        = null,
                                    IRunnerResultProcessor output = null,
                                    string logDirectory           = null,
                                    bool showGcMessages           = false)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            Debug.EnableGCMessages(showGcMessages);

            var dispatch = new FeedbackDispatcher();

            if (output != null)
            {
                dispatch.Add(output);
            }
            dispatch.Add(new FeedbackToDebug());
            if (BuildAutomation.InBuild)
            {
                dispatch.Add(new FeedbackToLogFiles());
            }
            else if (logDirectory != null)
            {
                dispatch.Add(new FeedbackToLogFiles(logDirectory));
            }

            TestRunner runner = new TestRunner(assembly, input, dispatch);

            runner.ExecuteTests()
            .Wait();

            if (!BuildAutomation.InBuild)
            {
                Thread.Sleep(Timeout.Infinite);
            }
            else
            {
                Thread.CurrentThread.Abort();
                //TaskScheduler.UnusedThreadTimeoutMilliseconds = 10;
                //Task.Run(() => { });
            }

            //todo: handle shutting down of emulator!
        }