/// <summary> /// Publish final results. If not yet ready, will keep waiting around /// as a work item until it is done. /// </summary> private void PublishFinalResults() { if (TestService != null && TestService.BusyServiceReferenceCounter > 0) { if (_harnessTasks == null) { _harnessTasks = new CompositeWorkItem(); } _harnessTasks.Enqueue(new CallbackWorkItem(() => { })); _harnessTasks.Enqueue(new CallbackWorkItem(PublishFinalResults)); if (RunDispatcher == null) { RunDispatcher = RunDispatcher.Create(RunNextStep, Dispatcher); RunDispatcher.Run(); } } else { _harnessTasks = null; RunDispatcher = null; PublishFinalResult(); if (IsReportingTestServiceConnected()) { SetOverallStatus("Reporting complete..."); } } }
/// <summary> /// Create a new assembly manager, takes in the harness, provider /// reference and actual IAssembly object. /// </summary> /// <param name="runFilter">The test run filter object.</param> /// <param name="testHarness">Harness object.</param> /// <param name="provider">The unit test metadata provider.</param> /// <param name="testAssembly">The test assembly metadata object.</param> public AssemblyManager(TestRunFilter runFilter, UnitTestHarness testHarness, IUnitTestProvider provider, IAssembly testAssembly) : base(testHarness, provider) { _filter = runFilter; _assembly = testAssembly; _testClasses = new CompositeWorkItem(); ClassInstances = new TestClassInstanceDictionary(); }
/// <summary> /// A container type that handles an entire test class throughout the /// test run. /// </summary> /// <param name="filter">Test run filter object.</param> /// <param name="testHarness">The unit test harness.</param> /// <param name="testClass">The test class metadata interface.</param> /// <param name="instance">The object instance.</param> /// <param name="provider">The unit test provider.</param> public TestClassManager(TestRunFilter filter, UnitTestHarness testHarness, ITestClass testClass, object instance, IUnitTestProvider provider) : base(testHarness, provider) { _filter = filter; _testClass = testClass; _testExecutionQueue = new CompositeWorkItem(); _instance = instance; }
/// <summary> /// Listener event for any unhandled exceptions. /// </summary> /// <param name="sender">Sender object instance.</param> /// <param name="e">Event arguments.</param> private void GlobalUnhandledExceptionListener(object sender, EventArgs e) { if (DispatcherStack.CurrentCompositeWorkItem is CompositeWorkItem) { CompositeWorkItem cd = (CompositeWorkItem)DispatcherStack.CurrentCompositeWorkItem; Exception exception = GlobalExceptionHandler.GetExceptionObject(e); cd.WorkItemException(exception); GlobalExceptionHandler.ChangeExceptionBubbling(e, /* handled */ true); } else { GlobalExceptionHandler.ChangeExceptionBubbling(e, /* handled */ false); } }
/// <summary> /// Pop a dispatcher off the stack. /// </summary> /// <returns>Returns the top-most container. Throws an /// InvalidOperationException if none is available.</returns> public CompositeWorkItem Pop() { if (CurrentCompositeWorkItem == null) { throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestHarness_RunNextStep_NoCompositeWorkItemsExist); } CompositeWorkItem queue = _stack.Peek(); if (queue != null) { _stack.Pop(); } return(queue); }
/// <summary> /// Push a new dispatcher onto the stack. /// </summary> /// <param name="composite">The composite work item to push.</param> public void Push(CompositeWorkItem composite) { _stack.Push(composite); }
/// <summary> /// Creates the set of harness tasks to run and hooks up to the Complete event. /// </summary> private void CreateHarnessTasks() { _harnessTasks = new CompositeWorkItem(); _harnessTasks.Complete += HarnessComplete; }
/// <summary> /// Event fired at the completion of the harness' work. /// </summary> /// <param name="sender">Sender object instance.</param> /// <param name="e">Event arguments.</param> private void HarnessComplete(object sender, EventArgs e) { LogWriter.UnitTestHarnessStage(this, HarnessName, TestStage.Finishing); _harnessTasks = null; }