public void RunTestSuite() { _events = new ConcurrentQueue <TestEvent>(); var dispatcher = new ParallelWorkItemDispatcher(4); var context = new TestExecutionContext(); context.Dispatcher = dispatcher; context.Listener = this; dispatcher.ShiftStarting += (shift) => { _events.Enqueue(new TestEvent() { Action = TestAction.ShiftStarted, ShiftName = shift.Name }); }; dispatcher.ShiftFinished += (shift) => { _events.Enqueue(new TestEvent() { Action = TestAction.ShiftFinished, ShiftName = shift.Name }); }; var workItem = TestBuilder.CreateWorkItem(_testSuite, context); dispatcher.Start(workItem); workItem.WaitForCompletion(); _result = workItem.Result; }
public void ParallelExeutionStrategy_TestFixture(ParallelScope testScope, ParallelScope contextScope, string expectedStrategy) { _testFixture.Properties.Set(PropertyNames.ParallelScope, testScope); _context.ParallelScope = contextScope; WorkItem work = WorkItem.CreateWorkItem(_testFixture, TestFilter.Empty); work.InitializeContext(_context); // We use a string for expected because the ExecutionStrategy enum is internal and can't be an arg to a public method Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo(expectedStrategy)); }
public void ParallelExecutionStrategy_TestCase(ParallelScope testScope, ParallelScope contextScope, string expectedStrategy) { _testMethod.Properties.Set(PropertyNames.ParallelScope, testScope); _context.ParallelScope = contextScope; WorkItem work = WorkItem.CreateWorkItem(_testMethod, TestFilter.Empty); work.InitializeContext(_context); // We use a string for expected because the ExecutionStrategy enum is internal and can't be an arg to a public method Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo(expectedStrategy)); // Make context single threaded - should always be direct _context.IsSingleThreaded = true; Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo("Direct")); }
public void CreateDispatcher() { _dispatcher = new ParallelWorkItemDispatcher(LEVEL_OF_PARALLELISM); }