void AddTestModule(string filePath) { Assembly assembly = Assembly.LoadFrom(filePath); foreach (Type type in assembly.GetTypes()) { if (type.IsPublic) { if (!type.IsAbstract) { Type typeInterface = type.GetInterface("TTSM2.Definitions.ITestModule", true); if (typeInterface != null) { TestModuleInfo tmi = FindTestModule(type.Name); if (tmi != null) { continue; } tmi = new TestModuleInfo(type.Name); tmi.AssemblyPath = filePath; object instance = Activator.CreateInstance(assembly.GetType(type.ToString())); //object instance = assembly.CreateInstance(type.FullName); tmi.Instance = (ITestModule)instance; tmi.Instance.SetLogger(te.DebugLogger); tmi.Instance.SetGlobalVariables(te.GlobalVariables); tmi.Instance.Initialize(); testModules.Add(type.Name, tmi); } } } } }
public void UnloadTestModules() { foreach (var item in testModules) { TestModuleInfo pi = item.Value; pi.Instance.Cleanup(); pi.Instance = null; } testModules.Clear(); }