InitializeContext() публичный Метод

Initialize the TestExecutionContext. This must be done before executing the WorkItem.
Originally, the context was provided in the constructor but delaying initialization of the context until the item is about to be dispatched allows changes in the parent context during OneTimeSetUp to be reflected in the child.
public InitializeContext ( TestExecutionContext context ) : void
context TestExecutionContext The TestExecutionContext to use
Результат void
Пример #1
0
        public void CreateWorkItems()
        {
            IMethodInfo method = new MethodWrapper(typeof(DummyFixture), "DummyTest");
            ITest test = new TestMethod(method);
            _workItem = WorkItem.CreateWorkItem(test, TestFilter.Empty);

            _context = new TestExecutionContext();
            _workItem.InitializeContext(_context);
        }
Пример #2
0
        public void CreateWorkItems()
        {
            IMethodInfo method = new MethodWrapper(typeof(DummyFixture), "DummyTest");
            ITest       test   = new TestMethod(method);

            _workItem = WorkItemBuilder.CreateWorkItem(test, TestFilter.Empty);

            _context = new TestExecutionContext();
            _workItem.InitializeContext(_context);
        }
Пример #3
0
        public void CreateWorkItems()
        {
            FixtureMethod method = typeof(DummyFixture).GetFixtureMethod("DummyTest");
            ITest         test   = new TestMethod(method);

            _workItem = WorkItemBuilder.CreateWorkItem(test, TestFilter.Empty);

            _context = new TestExecutionContext();
            _workItem.InitializeContext(_context);
        }
        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"));
        }