本文整理汇总了C#中TestCase.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# TestCase.GetType方法的具体用法?C# TestCase.GetType怎么用?C# TestCase.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase
的用法示例。
在下文中一共展示了TestCase.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAll
public override void AddAll(TestCase test)
{
// Do like super's
base.AddAll(test);
// If test invalid
if (null == test) {
// Error
throw new Exception("Invalid test case encountered.");
}
// For each method in the test case
Type type = test.GetType();
foreach (MethodInfo method in type.GetMethods()) {
// For each unit test attribute
foreach (System.Object obj in method.GetCustomAttributes(typeof(CoroutineUnitTest), false)) {
// If attribute is valid
Attribute testAtt = obj as Attribute;
if (null != testAtt) {
// If type has constructors
ConstructorInfo[] ci = type.GetConstructors();
if (0 < ci.Length) {
// Add the test
TestCase tmp = ci[0].Invoke(null) as TestCase;
tmp.SetTestMethod(method.Name);
coroutineTests.Add(tmp);
}
}
}
}
}
示例2: ListTestsInBinary
internal static IEnumerable<TestCase> ListTestsInBinary(string source)
{
var tests = new List<TestCase>();
var listOutput = Utility.runExe(source, "--list-tests");
// Match a test case out of the output.
const string regexStr = @"\r?\n[ ]{2}(?<name>[^\r\n]*)(?:\r?\n[ ]{4}(?<name>[^ ][^\r\n]*))*(?:\r?\n[ ]{6}(?<tag>\s*\[[^\r\n]*\])*)?";
foreach (Match match in Regex.Matches(listOutput, regexStr))
{
IEnumerable<string> nameLines = match.Groups["name"].Captures.OfType<Capture>().Select(x => x.Value).ToList();
var fullyQuallifiedName = (nameLines.Count() == 1) ? nameLines.First() : nameLines.First() + "*";
var test = new TestCase(fullyQuallifiedName, CatchTestExecutor.ExecutorUri, source)
{
DisplayName = nameLines.Aggregate((x, y) => x + " " + y)
};
// Add test tags as traits.
if (test.GetType().GetProperty("Traits") != null) //< Don't populate traits on older versions of VS.
{
foreach (Capture tag in match.Groups["tag"].Captures)
{
test.Traits.Add("Tags", tag.Value);
}
}
tests.Add(test);
}
return tests;
}