-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
TestRunner.cs
50 lines (44 loc) · 1.29 KB
/
TestRunner.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using cs_testcommon;
using System;
using System.Reflection;
namespace cs_unittest
{
/// <summary>
/// Helper to perform leak testing
/// </summary>
public class TestRunner : MarshalByRefObject, ITestRunner
{
public string Run(string type, string method)
{
var testType = Type.GetType(type);
var testObject = Activator.CreateInstance(testType);
try
{
var m = testType.GetMethod(method);
if (m == null)
{
return string.Format("TestRunner: {0}.{1} not found", type, method);
}
m.Invoke(testObject, null);
}
catch (Exception ex)
{
var tex = ex as TargetInvocationException;
if (tex != null)
{
ex = tex.InnerException;
}
return string.Format("{0}\n{1}\n#-#-#-#-#-#-#{2}", ex.GetType(), ex.Message, ex.StackTrace);
}
finally
{
var disposable = testObject as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
return null;
}
}
}