[2005] Recursive Reflection Autotesting
I have 4-5 mainframe systems mapped to class libraries, so that my coworkers can easily pull data from any of those systems. Occasionally the mainframes themselves have screen/field changes. and occasionally we take on a new project that needs new fields,screens, or another mainframe mapped.
I'm hoping to implement some reflection based automatic testing of each of the data fields. so that I can call testAll on the session class and it recursively iterates all sub screens or objects on itself.
Sample idea:
Code:
class tn3270
screenA as screenCustomer
public function Testall as string 'function I'm hoping to design
end class
class Screencustomer
public readonly property Name as string
public readonly property DoB as string
public readonly property subScreenA as screenDocumentsSigned
public function subScreenB as screenVisitsMade
public function TestAll as string 'should be same function/functioncall
end class
the test all function should be able to iterate all of its read-only properties with name and value ( I already have this piece), but also able to check it's properties or functions that don't require an argument and return an object for having the testAll function as an attribute and invoking that where applicable.
Any ideas/pointers? I think this would be the starting point for such a thing but not sure which memberTypes are valid possibilities, nor how to check if something is an object or a basetype(like integer, and hence may throw an exception if you try to look into it as if it was an object)
Code:
Public Function RecursiveTest(ByVal obj As Object) As String
Dim oMembersInfo(), oMemberInfo As Reflection.MemberInfo
oMembersInfo = obj.GetType().GetMembers
Dim oAttribs() As Object
'oMembersInfo = DirectCast(GetType(obj.gettype).GetMembers, Reflection.MemberInfo)
For Each oMemberInfo In oMembersInfo
oAttribs = oMemberInfo.GetCustomAttributes(False)
If oAttribs.Length > 0 Then
Select Case oMemberInfo.MemberType
Case MemberTypes.All
Stop
Case MemberTypes.Constructor
Case MemberTypes.Custom
Stop
Case MemberTypes.Event
Case MemberTypes.Field
Stop
Case MemberTypes.Method
Case MemberTypes.NestedType
Stop
Case MemberTypes.Property
Stop
End Select
End If
Next
End Function