コード例 #1
0
        protected override void OnResume()
        {
            base.OnResume();

            var testAssemblies = GetAssembliesForTest();
            var testAssemblyEnumerator = testAssemblies.GetEnumerator();
            var testRunner = new TestRunner();

            // Clear the test result list
            TestRunContext.Current.TestResults.Clear();

            _testResultsAdapter.NotifyDataSetInvalidated();
            _testResultsAdapter.NotifyDataSetChanged();

            // Add a test listener for the test runner
            testRunner.AddListener(new UITestListener((TestResultsListAdapter)ListAdapter));

            // Start the test process in a background task
            Task.Factory.StartNew(() =>
            {
                while (testAssemblyEnumerator.MoveNext())
                {
                    try
                    {
                        var assembly = testAssemblyEnumerator.Current;
                        testRunner.Run(assembly);
                    }
                    catch (Exception ex)
                    {
                        ShowErrorDialog(ex);
                    }
                }
            });
        }
コード例 #2
0
        private void RunTests()
        {
            var testAssemblies = GetAssembliesForTest();
            var testAssemblyEnumerator = testAssemblies.GetEnumerator();
            var testRunner = new TestRunner();

            _testResultsAdapter.NotifyDataSetInvalidated();
            _testResultsAdapter.NotifyDataSetChanged();

            // Add a test listener for the test runner
            testRunner.AddListener(new UITestListener((TestResultsListAdapter)ListAdapter));

            // Start the test process in a background task
            Task.Factory.StartNew(() =>
            {
                while (testAssemblyEnumerator.MoveNext())
                {
                    try
                    {
                        var assembly = testAssemblyEnumerator.Current;
                        testRunner.Run(assembly);
                    }
                    catch (Exception ex)
                    {
                        ShowErrorDialog(ex);
                    }
                }
                RunOnUiThread(() => Toast.MakeText(this, "Test run finished", ToastLength.Short).Show());
            });
        }