/// <summary> /// Builds a test from the method. /// </summary> /// <param name="method">A method which defines the test.</param> /// <returns>A new test suite containing the test.</returns> public ITestSuite BuildTest(MethodInfo method) { ITestSuite ts = BuildTestSuite(method.DeclaringType.Assembly, method.DeclaringType.Namespace); foreach (IFixture f in ts.Fixtures) { if (f.FixtureType != method.DeclaringType) { ts.RemoveFixture(f); } else { foreach (ITest t in f.Tests) { if (t.TestMethod == null || t.TestMethod.Name != method.Name) { f.RemoveTest(t); } } } } // None of the child test suites are required for a single method test. foreach (ITestSuite cts in ts.TestSuites) { ts.RemoveTestSuite(cts); } return(ts); }
/// <summary> /// Builds a test fixture from a type. /// </summary> /// <param name="type">A type which defines the test fixture.</param> /// <returns>A new test suite containing the test fixture.</returns> public ITestSuite BuildTest(Type type) { ITestSuite ts = BuildTestSuite(type.Assembly, type.Namespace); foreach (IFixture f in ts.Fixtures) { if (f.Name != type.Name) { ts.RemoveFixture(f); } } // None of the child test suites are required for a single method test. foreach (ITestSuite cts in ts.TestSuites) { ts.RemoveTestSuite(cts); } return(ts); }