private TestCommand MakeOneTimeTearDownCommand(List <SetUpTearDownItem> setUpTearDownItems, List <TestActionItem> actions) { TestCommand command = new EmptyTestCommand(Test); // For Theories, follow with TheoryResultCommand to adjust result as needed if (Test.TestType == "Theory") { command = new TheoryResultCommand(command); } // Create the AfterTestAction commands int index = actions.Count; while (--index >= 0) { command = new AfterTestActionCommand(command, actions[index]); } // Create the OneTimeTearDown commands foreach (SetUpTearDownItem item in setUpTearDownItems) { command = new OneTimeTearDownCommand(command, item); } // Dispose of fixture if necessary if (Test is IDisposableFixture && typeof(IDisposable).IsAssignableFrom(Test.TypeInfo.Type)) { command = new DisposeFixtureCommand(command); } return(command); }
private TestCommand MakeOneTimeSetUpCommand(List <SetUpTearDownItem> setUpTearDown, List <TestActionItem> actions) { TestCommand command = new EmptyTestCommand(Test); // Add Action Commands int index = actions.Count; while (--index >= 0) { command = new BeforeTestActionCommand(command, actions[index]); } if (Test.TypeInfo != null) { // Build the OneTimeSetUpCommands foreach (SetUpTearDownItem item in setUpTearDown) { command = new OneTimeSetUpCommand(command, item); } // Construct the fixture if necessary if (!Test.TypeInfo.IsStaticClass) { command = new ConstructFixtureCommand(command); } } // Prefix with any IApplyToContext items from attributes foreach (var attr in Test.GetCustomAttributes <IApplyToContext>(true)) { command = new ApplyChangesToContextCommand(command, attr); } return(command); }