void IterateThroughTypes(Type[] types) { foreach (Type type in types) { TestFixtureAttribute testFixtureAttr = Attribute.GetCustomAttribute(type, typeof(TestFixtureAttribute), false) as TestFixtureAttribute; if (testFixtureAttr != null || !requireTestFixture) { MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo method in methods) { TestAttribute testAttr = Attribute.GetCustomAttribute(method, typeof(TestAttribute), false) as TestAttribute; SetUpAttribute setupAttr = Attribute.GetCustomAttribute(method, typeof(SetUpAttribute), false) as SetUpAttribute; TearDownAttribute teardownAttr = Attribute.GetCustomAttribute(method, typeof(TearDownAttribute), false) as TearDownAttribute; if (testAttr != null) { try { ConstructorInfo[] constructors = type.GetConstructors(); object curTestObject = null; if (constructors.Length > 0) { curTestObject = constructors[0].Invoke(null); } if (curTestObject != null) { testMethods[method] = curTestObject; } } catch { // Fail the test here? } } else if (setupAttr != null) { setupMethods.Add(type, method); } else if (teardownAttr != null) { teardownMethods.Add(type, method); } } } } }
public void TestTearDownAttribute() { TearDownAttribute tearDown = new TearDownAttribute(); }