private void DoRegularTest(TestAgent test, TestUnit testUnit, Object container, Object testedObject, Int32 iterationIndex) { var timeMonitor = new Stopwatch(); var memoryMonitor = new MemoryMonitor(); Object[] invokeParameters = null; if (test.TestedType != null) { invokeParameters = new Object[1] { testedObject }; } memoryMonitor.Prepare(); memoryMonitor.Start(); timeMonitor.Start(); var result = testUnit.TestMethod.Invoke(container, invokeParameters); timeMonitor.Stop(); memoryMonitor.Stop(); //skip results of first call storing if (iterationIndex != -1) { bool isValid = true; if (testUnit.ValidatorMethod != null) { invokeParameters = new Object[1] { result }; isValid = (bool)testUnit.ValidatorMethod.Invoke(container, invokeParameters); } var runResult = new PassResult(timeMonitor.Elapsed, memoryMonitor.Usage, test.Metrics, isValid); _resultHandler.AddResult(runResult, testUnit.Id, iterationIndex); _progressHandler.PortionDone(); } }
private static PassResult DoJITTest(TestAgent agent, TestUnit testUnit, Object container, Object testedObject, Int32 iterationIndex) { var timeMonitor = new Stopwatch(); var memoryMonitor = new MemoryMonitor(); Object[] invokeParameters = null; if (agent.TestedType != null) { invokeParameters = new Object[1] { testedObject }; } //todo: Create delegates to call instead of Invoking //Test test = (Test)Delegate.CreateDelegate(typeof(Test), container, testUnit.TestMethod); Object result = null; Assembly.Load("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); memoryMonitor.Prepare(); memoryMonitor.Start(); timeMonitor.Start(); result = testUnit.TestMethod.Invoke(container, invokeParameters); //test(); timeMonitor.Stop(); memoryMonitor.Stop(); bool isValid = true; if (testUnit.ValidatorMethod != null) { invokeParameters = new Object[1] { result }; isValid = (bool)testUnit.ValidatorMethod.Invoke(container, invokeParameters); } var runResult = new PassResult(timeMonitor.Elapsed, memoryMonitor.Usage, agent.Metrics, isValid); return runResult; }