1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Reflection;
7
using ICSharpCode.NRefactory.VB.Ast;
8
using ICSharpCode.NRefactory.VB.Parser;
10
namespace ICSharpCode.NRefactory.VB.Tests
13
public class StructuralTest
16
// public void TestToStringMethods()
18
// Type[] allTypes = typeof(INode).Assembly.GetTypes();
20
// foreach (Type type in allTypes) {
21
// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null) {
22
// MethodInfo methodInfo = type.GetMethod("ToString", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
23
// Assert.IsNotNull(methodInfo, "ToString() not found in " + type.FullName);
29
// public void TestUnitTests()
31
// Type[] allTypes = typeof(StructuralTest).Assembly.GetTypes();
33
// foreach (Type type in allTypes) {
34
// if (type.GetCustomAttributes(typeof(TestFixtureAttribute), true).Length > 0) {
35
// foreach (MethodInfo m in type.GetMethods()) {
36
// if (m.IsPublic && m.ReturnType == typeof(void) && m.GetParameters().Length == 0) {
37
// if (m.GetCustomAttributes(typeof(TestAttribute), true).Length == 0) {
38
// Assert.Fail(type.Name + "." + m.Name + " should have the [Test] attribute!");
47
// public void TestAcceptVisitorMethods()
49
// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes();
51
// foreach (Type type in allTypes) {
52
// if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null) {
53
// MethodInfo methodInfo = type.GetMethod("AcceptVisitor", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public);
54
// Assertion.AssertNotNull("AcceptVisitor() not found in " + type.FullName, methodInfo);
60
// public void TestIAstVisitor()
62
// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes();
63
// Type visitor = typeof(IAstVisitor);
65
// foreach (Type type in allTypes) {
66
// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) {
67
// MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null);
68
// Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found");
69
// Assert.AreEqual(2, methodInfo.GetParameters().Length);
70
// ParameterInfo first = methodInfo.GetParameters()[0];
71
// Assert.AreEqual(Char.ToLower(first.ParameterType.Name[0]) + first.ParameterType.Name.Substring(1), first.Name);
73
// ParameterInfo second = methodInfo.GetParameters()[1];
74
// Assert.AreEqual(typeof(System.Object), second.ParameterType);
75
// Assert.AreEqual("data", second.Name);
81
// public void TestAbstractAstVisitorVisitor()
83
// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes();
84
// Type visitor = typeof(AbstractAstVisitor);
86
// foreach (Type type in allTypes) {
87
// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) {
88
// MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null);
89
// Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found");
91
// Assert.AreEqual(2, methodInfo.GetParameters().Length);
92
// ParameterInfo first = methodInfo.GetParameters()[0];
93
// Assert.AreEqual(Char.ToLower(first.ParameterType.Name[0]) + first.ParameterType.Name.Substring(1), first.Name);
95
// ParameterInfo second = methodInfo.GetParameters()[1];
96
// Assert.AreEqual(typeof(System.Object), second.ParameterType);
97
// Assert.AreEqual("data", second.Name);