private void Initialize() { try { Reflect.CheckFixtureType(fixtureType); IList categories = Reflect.GetCategories(fixtureType); CategoryManager.Add(categories); this.Categories = categories; this.fixtureSetUp = Reflect.GetFixtureSetUpMethod(fixtureType); this.fixtureTearDown = Reflect.GetFixtureTearDownMethod(fixtureType); this.IsExplicit = Reflect.HasExplicitAttribute(fixtureType); if (Reflect.HasIgnoreAttribute(fixtureType)) { this.ShouldRun = false; this.IgnoreReason = Reflect.GetIgnoreReason(fixtureType); } this.Description = Reflect.GetDescription(fixtureType); MethodInfo [] methods = fixtureType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { TestCase testCase = TestCaseBuilder.Make(fixtureType, method); if (testCase != null) { testCase.AssemblyKey = this.AssemblyKey; this.Add(testCase); } } if (this.CountTestCases() == 0) { this.ShouldRun = false; this.IgnoreReason = this.Name + " does not have any tests"; } } catch (InvalidTestFixtureException exception) { this.ShouldRun = false; this.IgnoreReason = exception.Message; } }
// TODO: Only used in tests public object BuildTestFixture(Type fixtureType) { Reflect.CheckFixtureType(fixtureType); object testFixture; ConstructorInfo ctor = Reflect.GetConstructor(fixtureType); try { testFixture = ctor.Invoke(Type.EmptyTypes); } catch (Exception ex) { throw new InvalidTestFixtureException(ctor.Name + " threw a exception", ex); } if (testFixture == null) { throw new InvalidTestFixtureException(ctor.Name + " cannot be invoked"); } return(testFixture); }