Skip to content

Commit

Permalink
Add a warning that the AS contains nodes orphaned and inaccessible fo…
Browse files Browse the repository at this point in the history
…r browsing starting from the Root node #529

-Prototyping with that - working on an algorithm to compare nodes in UANodesSet and ModelDesign.
- UT 👍
  • Loading branch information
mpostol committed Feb 23, 2021
1 parent 3faf0d5 commit e5e428b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,29 @@ public void eoursel510Test()
addressSpace.ValidateAndExportModel(model);
Assert.AreEqual<int>(5, traceContext.TraceList.Count);
IEnumerable<NodeFactoryBase> nodes = testingModelFixture.Export();
Assert.AreEqual(21, nodes.Count< NodeFactoryBase>());
Assert.AreEqual(21, nodes.Count<NodeFactoryBase>());
Dictionary<string, NodeFactoryBase> nodesDictionary = nodes.ToDictionary<NodeFactoryBase, string>(x => x.SymbolicName.Name);
AddressSpaceContext asContext = addressSpace as AddressSpaceContext;
//TODO Add a warning that the AS contains nodes orphaned and inaccessible for browsing starting from the Root node #529
IEnumerable<IUANodeContext> allNodes = null;
asContext.UTValidateAndExportModel(1, x => allNodes = x);
Assert.IsNotNull(allNodes);
List<IUANodeContext> orphanedNodes = new List<IUANodeContext>();
List<IUANodeContext> processedNodes = new List<IUANodeContext>();
foreach (IUANodeContext item in allNodes)
{
if (!nodesDictionary.ContainsKey(item.BrowseName.ToString()))
if (!nodesDictionary.ContainsKey(item.BrowseName.Name))
{
orphanedNodes.Add(item);
Debug.WriteLine($"The following node has been removed from the model: {item.ToString()}");
}
else
processedNodes.Add(item);
}
Debug.WriteLine($"The recovered information model contains {nodes.Count<NodeFactoryBase>()} nodes");
Debug.WriteLine($"The recovered information model contains {nodesDictionary.Count} nodes");
Debug.WriteLine($"The source information model contains {allNodes.Count<IUANodeContext>()} nodes");
Debug.WriteLine($"Number of nodes not considered for export {orphanedNodes.Count<IUANodeContext>()}");
Debug.WriteLine($"Number of nodes not considered for export {orphanedNodes.Count}");
Debug.WriteLine($"Number of processed nodes {processedNodes.Count}");
}
}

Expand Down

0 comments on commit e5e428b

Please sign in to comment.