📄 maintest.cs
字号:
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace SmartAnswerCall.处理类
{
public class MainTest
{
private int m_numTests = 0;
public DisplayLineDelegate m_showLine = null;
protected TestInfo[] m_tests = null;
public MainTest(DisplayLineDelegate showLineFunc)
{
this.m_numTests = 0;
this.m_tests = new TestInfo[0x20];
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
if (type.IsClass)
{
foreach (MethodInfo info in type.GetMethods())
{
if (string.Compare(info.Name, "TestProc", false) == 0)
{
ParameterInfo[] parameters = info.GetParameters();
if ((info.IsStatic && info.IsPublic) && (parameters.Length == 1))
{
if (this.m_numTests == 0x1f)
{
return;
}
this.m_tests[this.m_numTests] = new TestInfo();
this.m_tests[this.m_numTests].m_methInfo = info;
this.m_tests[this.m_numTests].m_name = type.Name;
this.m_numTests++;
}
}
}
}
}
this.m_showLine = showLineFunc;
}
public string GetTestName(int index)
{
return this.m_tests[index].m_name;
}
public void RunTest(int index)
{
this.m_showLine(string.Format("****Begin {0}****", this.m_tests[index].m_name));
try
{
object[] parameters = new object[] { this.m_showLine };
this.m_tests[index].m_methInfo.Invoke(this, parameters);
}
catch (Exception exception)
{
this.m_showLine(string.Format("FAILURE: {0}", exception.Message));
}
this.m_showLine(string.Format("****End {0}****", this.m_tests[index].m_name));
this.m_showLine("");
}
public int NumTests
{
get
{
return this.m_numTests;
}
}
public delegate void DisplayLineDelegate(string txt);
protected class TestInfo
{
public MethodInfo m_methInfo = null;
public string m_name = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -