internal ResultStruct Invoke(Dictionary <int, TestClassBase> testClassDictionary) { ResultStruct resultStruct = new ResultStruct(); try { Assembly assembly = TestReflection.LoadTestAssembly(TestProperties.ExpandString(TestAssembly)); Type testClassType = TestReflection.GetTestClass(assembly, TestClass); TestAssert.IsNotNull(testClassType, "The test class specified \"{0}\" cannot be located or is not a valid test class. " + "Check the test class's TestClassAttribute has been set.", TestClass); Type[] types = TestParameters.GetParameterTypes(); MethodInfo testMethod = TestReflection.GetTestMethod(testClassType, TestMethod, types); TestAssert.IsNotNull(testMethod, "The test method specified \"{0}\" cannot be located or it is not a valid test method. " + "Check the test method signature is correct and the TestMethodAttribute had been set.", TestMethod); TestClassBase testClassInstance; var virtualUser = Thread.CurrentThread.Name; int hashcode = testClassType.GetHashCode() + virtualUser.GetHashCode(); if (testClassDictionary != null && testClassDictionary.TryGetValue(hashcode, out testClassInstance)) { testClassInstance.TestMessage = null; testClassInstance.ResetTestCheckCollection(); testClassInstance.ResetTestWarningCollection(); testClassInstance.ResetTestDataCollection(); testClassInstance.TestVerdict = TestVerdict.Pass; } else { testClassInstance = Activator.CreateInstance(testClassType) as TestClassBase; testClassInstance.VirtualUser = virtualUser; if (testClassDictionary != null) { testClassDictionary.Add(hashcode, testClassInstance); } } object[] values = TestParameters.GetParameterValues(); PropertyInfo property = null; //TODO - this needs to be abstractedfrom TestExecutor class. //if (!TestExecutor.SuppressExecution) if (true) { resultStruct.StartTime = DateTime.Now; resultStruct.TestVerdict = (TestVerdict)testMethod.Invoke(testClassInstance, values); resultStruct.EndTime = DateTime.Now; property = testClassType.GetProperty("TestMessage"); resultStruct.TestMessage = (string)property.GetValue(testClassInstance, null); } else { resultStruct.TestVerdict = TestVerdict.Pass; resultStruct.TestMessage = "Test runtime execution has been suppressed."; } // Get properties property = testClassType.GetProperty("TestChecks"); resultStruct.TestChecks = (TestCheckCollection)property.GetValue(testClassInstance, null); property = testClassType.GetProperty("TestWarnings"); resultStruct.TestWarnings = (TestWarningCollection)property.GetValue(testClassInstance, null); property = testClassType.GetProperty("TestData"); resultStruct.TestData = (TestDataCollection)property.GetValue(testClassInstance, null); resultStruct = determineTestVerdict(resultStruct); } catch (Exception e) { if (e is System.Reflection.ReflectionTypeLoadException) { var typeLoadException = e as ReflectionTypeLoadException; var loaderExceptions = typeLoadException.LoaderExceptions; } resultStruct.TestVerdict = TestVerdict.Error; resultStruct.TestMessage += e.ToString(); } return(resultStruct); }