public void Run(UnitTestSettings settings) { // Avoid having the Run method called twice if (_harness != null) { return; } // Track the most recent system in use _system = this; _harness = settings.TestHarness; if (_harness == null) { throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestSystem_Run_NoTestHarnessInSettings); } _harness.Initialize(settings); _harness.TestHarnessCompleted += (sender, args) => OnTestHarnessCompleted(args); _harness.Run(); }
/// <summary> /// Creates a new TestPage visual that in turn will setup and begin a /// unit test run. /// </summary> /// <param name="settings">Test harness settings to be applied.</param> /// <returns>A new RootVisual.</returns> /// <remarks>Assumes the calling assembly is a test assembly.</remarks> public static UIElement CreateTestPage(UnitTestSettings settings) { UnitTestSystem system = new UnitTestSystem(); Type testPageType = Environment.OSVersion.Platform == PlatformID.WinCE ? typeof(MobileTestPage) : typeof(TestPage); Type testPageInterface = typeof(ITestPage); if (settings.TestPanelType != null && testPageInterface.IsAssignableFrom(settings.TestPanelType)) { testPageType = settings.TestPanelType; } object testPage; try { // Try creating with an instance of the test harness testPage = Activator.CreateInstance(testPageType, settings.TestHarness); } catch { // Fall back to a standard instance only testPage = Activator.CreateInstance(testPageType); } PrepareTestService(settings, () => system.Run(settings)); // NOTE: A silent failure would be if the testPanel is not a // UIElement, and it returns anyway. return testPage as UIElement; }
/// <summary> /// Creates a new TestPage visual that in turn will setup and begin a /// unit test run. /// </summary> /// <param name="settings">Test harness settings to be applied.</param> /// <returns>A new RootVisual.</returns> /// <remarks>Assumes the calling assembly is a test assembly.</remarks> public static UIElement CreateTestPage(UnitTestSettings settings) { UnitTestSystem system = new UnitTestSystem(); PrepareTestService(settings, () => system.Run(settings)); return new TestPage(); }