private CollectMethods ( Node node, bool testErrors, List |
||
node | Node | |
testErrors | bool | |
methods | List |
|
return | bool |
private bool CollectMethods(Node node, bool testErrors, List<TestMethod> methods)
{
if (node == null || node.NodeClass != NodeClass.Method)
{
return true;
}
MethodNode method = node as MethodNode;
IList<INode> parents = Session.NodeCache.Find(
node.NodeId,
ReferenceTypeIds.HasComponent,
true,
true);
for (int ii = 0; ii < parents.Count; ii++)
{
ObjectNode parent = parents[ii] as ObjectNode;
if (parent != null && method != null)
{
if (!testErrors && parent.BrowseName.Name != "MethodTest")
{
continue;
}
bool found = false;
for (int jj = 0; jj < methods.Count; jj++)
{
if (Object.ReferenceEquals(method, methods[jj].Method))
{
found = true;
break;
}
}
if (found)
{
continue;
}
TestMethod test = new TestMethod();
test.Parent = parent;
test.Method = method;
test.InputArguments = new Argument[0];
test.OutputArguments = new Argument[0];
test.Inputs = new List<object>();
methods.Add(test);
if (methods.Count%25 == 0)
{
Log("Found for {0} Methods to Call", methods.Count);
}
IList<INode> properties = Session.NodeCache.Find(
method.NodeId,
ReferenceTypeIds.HasProperty,
false,
true);
for (int jj = 0; jj < properties.Count; jj++)
{
VariableNode property = properties[jj] as VariableNode;
if (property != null)
{
if (property.BrowseName == BrowseNames.InputArguments)
{
if (property.Value.Value == null)
{
DataValue value = Session.ReadValue(property.NodeId);
property.Value = value.WrappedValue;
}
test.InputArguments = (Argument[])ExtensionObject.ToArray(property.Value.Value as Array, typeof(Argument));
if (test.InputArguments == null)
{
Log(
"Could not read input arguments for method '{0}'. NodeId = {1}, Method = {2}",
test.Parent,
test.Parent.NodeId,
test.Method);
return false;
}
continue;
}
if (property.BrowseName == BrowseNames.OutputArguments)
{
if (property.Value.Value == null)
{
DataValue value = Session.ReadValue(property.NodeId);
property.Value = value.WrappedValue;
}
test.OutputArguments = (Argument[])ExtensionObject.ToArray(property.Value.Value as Array, typeof(Argument));
if (test.OutputArguments == null)
{
Log(
"Could not read output arguments for method '{0}'. NodeId = {1}, Method = {2}",
test.Parent,
test.Parent.NodeId,
test.Method);
return false;
}
continue;
}
}
}
}
}
return true;
}