Exemplo n.º 1
0
        /// <summary>
        /// Gets the command to be executed after all of the
        /// child tests are run.
        /// </summary>
        /// <returns>A TestCommand</returns>
        private static TestCommand MakeTearDownCommand(TestSuite suite, SetUpTearDownList setUpTearDown)
        {
            TestCommand command = new OneTimeTearDownCommand(suite, setUpTearDown);

            if (suite.TestType == "Theory")
            {
                command = new TheoryResultCommand(command);
            }

            return(command);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Construct a CompositeWorkItem for executing a test suite
        /// using a filter to select child tests.
        /// </summary>
        /// <param name="suite">The TestSuite to be executed</param>
        /// <param name="context">The execution context to be used</param>
        /// <param name="childFilter">A filter used to select child tests</param>
        public CompositeWorkItem(TestSuite suite, TestExecutionContext context, ITestFilter childFilter)
            : base(suite, context)
        {
            _suite = suite;
            SetUpTearDownList setUpTearDown = null;

            if (suite.FixtureType != null)
            {
                setUpTearDown = new SetUpTearDownList(
                    suite.FixtureType, typeof(OneTimeSetUpAttribute), typeof(OneTimeTearDownAttribute));
            }

            _setupCommand    = MakeSetUpCommand(suite, setUpTearDown);
            _teardownCommand = MakeTearDownCommand(suite, setUpTearDown);
            _childFilter     = childFilter;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the command to be executed before any of
        /// the child tests are run.
        /// </summary>
        /// <returns>A TestCommand</returns>
        private static TestCommand MakeSetUpCommand(TestSuite suite, SetUpTearDownList setUpTearDown)
        {
            if (suite.RunState != RunState.Runnable && suite.RunState != RunState.Explicit)
            {
                return(new SkipCommand(suite));
            }

            TestCommand command = new OneTimeSetUpCommand(suite, setUpTearDown);

            if (suite.FixtureType != null)
            {
                IApplyToContext[] changes = (IApplyToContext[])suite.FixtureType.GetCustomAttributes(typeof(IApplyToContext), true);
                if (changes.Length > 0)
                {
                    command = new ApplyChangesToContextCommand(command, changes);
                }
            }

            return(command);
        }