/// <summary> /// Adds the given method as a setup method for this fixture. If the /// method is marked with a category, then it is stored in the setup /// method table. Without a category, the method is used as the default /// setup method. /// </summary> /// <param name="mi"></param> private void AddSetUpMethod(MethodEntry mi) { if( mi.Categories.IsEmpty ) { if( _defaultSetupMethod == null ) { _defaultSetupMethod = mi; } else if(FullName.Equals(mi.DeclaringTypeFullName)) { _defaultSetupMethod.Duplicates.Add(mi); } } else { foreach(var category in mi.Categories) { if( !_setupMethods.ContainsKey(category)) { _setupMethods.Add(category, mi); } else { _setupMethods[category].Duplicates.Add(mi); } } } }
/// <summary> /// Adds the given method as a tear down method for this fixture. If the /// method is marked with a category, then it is stored in the tear down /// method table. Without a category, the method is used as the default /// tear down method. /// </summary> /// <param name="method"></param> private void AddTearDownMethod(MethodEntry method) { if (method.Categories.IsEmpty) { if (_defaultTearDownMethod == null) { _defaultTearDownMethod = method; } else if (FullName.Equals(method.DeclaringTypeFullName)) { _defaultTearDownMethod.Duplicates.Add(method); } } else { foreach (var category in method.Categories) { if (!_tearDownMethods.ContainsKey(category)) { _tearDownMethods.Add(category, method); } else { _tearDownMethods[category].Duplicates.Add(method); } } } }
private bool InvokeMethod(MethodEntry testMethod) { if(testMethod != null) { testMethod.Listener = _testListener; try { _framework.InvokeMethod(FixtureInstance, testMethod); } catch(ThreadAbortException) { throw; } catch(Exception e) { ReportException(e, FullName, testMethod.Name); return false; } } return true; }