unittest.cs
来自「全功能c#编译器」· CS 代码 · 共 81 行
CS
81 行
/*
* Created by SharpDevelop.
* User: Andrea
* Date: 25.03.2004
* Time: 11:07
*
* To change this template use Tools | Options | File Templates.
*/
#if TEST
using System;
using System.Reflection;
using NUnit.Framework;
using ICSharpCode.CsVbRefactory.Parser.AST;
using ICSharpCode.CsVbRefactory.Parser;
namespace ICSharpCode.CsVbRefactory.Tests
{
[TestFixture]
public class StructuralTest
{
[Test]
public void TestToStringMethods()
{
Type[] allTypes = typeof(INode).Assembly.GetTypes();
foreach (Type type in allTypes) {
if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null) {
MethodInfo methodInfo = type.GetMethod("ToString", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
Assert.IsNotNull(methodInfo, "ToString() not found in " + type.FullName);
}
}
}
// [Test]
// public void TestAcceptVisitorMethods()
// {
// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes();
//
// foreach (Type type in allTypes) {
// if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null) {
// MethodInfo methodInfo = type.GetMethod("AcceptVisitor", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
// Assertion.AssertNotNull("AcceptVisitor() not found in " + type.FullName, methodInfo);
// }
// }
// }
[Test]
public void TestIASTVisitor()
{
Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes();
Type visitor = typeof(IASTVisitor);
foreach (Type type in allTypes) {
if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) {
MethodInfo methodInfo = visitor.GetMethod("Visit", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null);
Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found");
}
}
}
[Test]
public void TestIfINode()
{
Type[] allTypes = typeof(INode).Assembly.GetTypes();
foreach (Type type in allTypes) {
if (!type.IsInterface &&
!type.IsEnum &&
(type.BaseType == typeof(System.Delegate)) &&
(type.GetInterface(typeof(IASTVisitor).FullName) == null) &&
(type.FullName != "ICSharpCode.CsVbRefactory.Parser.Error") &&
(type.FullName != "ICSharpCode.CsVbRefactory.Tests.StructuralTest")) {
Assert.IsNotNull(type.GetInterface(typeof(INode).FullName), type.FullName + " is not INode");
}
}
}
}
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?