Skip to content

Commit

Permalink
Merge pull request #571 from mpostol/SemanticData-6.1.3
Browse files Browse the repository at this point in the history
Semantic data 6.1.3 => master fixes #529
  • Loading branch information
mpostol committed Apr 10, 2021
2 parents e4a31a0 + 7ad9944 commit 4842372
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void AddressSpaceContextConstructorTest()
List<IUANodeBase> _invalidNodes = new List<IUANodeBase>();
AddressSpaceWrapper _asp = new AddressSpaceWrapper();
_asp.AddressSpaceContext.UTAddressSpaceCheckConsistency(x => _invalidNodes.Add(x));
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
}

[TestMethod]
Expand All @@ -37,7 +37,7 @@ public void ReferencesCheckConsistencyTest()
{
AddressSpaceWrapper _asp = new AddressSpaceWrapper();
_asp.AddressSpaceContext.UTReferencesCheckConsistency((x, y, z, v) => Assert.Fail());
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
}

[TestMethod]
Expand All @@ -60,7 +60,7 @@ public void AddressSpaceContextContentCheck()
_asp.AddressSpaceContext.UTTryGetUANodeContext(ObjectTypes.FolderType, x => _content.Add(x));
Assert.AreEqual<int>(1, _content.Count);
Assert.IsTrue(new NodeId(ObjectTypes.FolderType) == _content[0].NodeIdContext);
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
}

[TestMethod]
Expand All @@ -75,7 +75,7 @@ public void AddressSpaceReferencesContentCheck()
_content.Clear();
_asp.AddressSpaceContext.UTGetReferences(ObjectIds.ObjectsFolder, x => _content.Add(x));
Assert.AreEqual<int>(3, _content.Count);
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
}

[TestMethod]
Expand Down Expand Up @@ -142,7 +142,7 @@ public void AddressSpaceContextValidateAndExportModelOpcUa()
{
AddressSpaceWrapper _asp = new AddressSpaceWrapper();
((IAddressSpaceContext)_asp.AddressSpaceContext).ValidateAndExportModel(new Uri(UAInformationModel.Namespaces.OpcUa));
_asp.TestConsistency(685, 2);
_asp.TestConsistency(684, 2);
Assert.AreEqual<string>(BuildError.WrongReference2Property.Identifier, _asp.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.ModelContainsErrors.Identifier, _asp.TraceList[1].BuildError.Identifier);
}
Expand All @@ -164,10 +164,10 @@ public void AddressSpaceContextValidateAndExportIndex0()
IEnumerable<IUANodeContext> _returnValue = null;
_asp.AddressSpaceContext.UTValidateAndExportModel(0, x => _returnValue = x);
Assert.AreEqual<int>(3909, (_returnValue.Count<IUANodeContext>()));
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
_asp.AddressSpaceContext.UTValidateAndExportModel(1, x => _returnValue = x);
Assert.AreEqual<int>(0, _returnValue.Count<IUANodeContext>());
_asp.TestConsistency(6, 0);
_asp.TestConsistency(5, 0);
}

[TestMethod]
Expand All @@ -177,9 +177,9 @@ public void ImportObjectTest()
AddressSpaceWrapper _asp = new AddressSpaceWrapper();
UANodeSet _newNodeSet = TestData.CreateNodeSetModel();
((IAddressSpaceContext)_asp.AddressSpaceContext).ImportUANodeSet(_newNodeSet);
_asp.TestConsistency(11, 1);
_asp.TestConsistency(9, 1);
_asp.AddressSpaceContext.UTAddressSpaceCheckConsistency(x => { Assert.Fail(); });
_asp.TestConsistency(11, 1);
_asp.TestConsistency(9, 1);
List<UAReferenceContext> _content = new List<UAReferenceContext>();
_asp.AddressSpaceContext.UTGetReferences(ObjectIds.RootFolder, x => _content.Add(x));
Assert.AreEqual<int>(4, _content.Count);
Expand All @@ -189,7 +189,7 @@ public void ImportObjectTest()
Assert.AreEqual<int>(4, _content.Count);
IEnumerable<IUANodeContext> _toExport = _content.Where<UAReferenceContext>(x => x.TargetNode.NodeIdContext.NamespaceIndex == 1).Select<UAReferenceContext, IUANodeContext>(x => x.TargetNode);
Assert.AreEqual<int>(1, _toExport.Count<IUANodeContext>());
_asp.TestConsistency(11, 1);
_asp.TestConsistency(09, 1);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@ public void UndefinedHasComponentTargetTestMethod()
Assert.AreEqual<int>(1, _log.TraceList.Count());
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(3, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<string>(BuildError.DanglingReferenceTarget.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.DanglingReferenceTarget.Identifier, _log.TraceList[1].BuildError.Identifier);
Assert.AreEqual<int>(5, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<string>(BuildError.NodeCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NodeCannotBeNull.Identifier, _log.TraceList[1].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.DanglingReferenceTarget.Identifier, _log.TraceList[2].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.DanglingReferenceTarget.Identifier, _log.TraceList[3].BuildError.Identifier);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public void NameInheritedFrom0Test()
Assert.AreEqual(3, 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);
Expand Down Expand Up @@ -110,7 +109,6 @@ public void eoursel510Test()
Assert.AreEqual(22, 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);
Expand Down
10 changes: 6 additions & 4 deletions SemanticData/UANodeSetValidation/AddressSpaceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public void GetBaseTypes(IUANodeContext rootNode, List<IUANodeContext> inheritan

//typeS

//TODO Add a warning that the AS contains nodes orphaned and inaccessible for browsing starting from the Root node #529
private class ValidationBuildErrorsHandling : IBuildErrorsHandling
{
public ValidationBuildErrorsHandling(Action<TraceMessage> traceEvent)
Expand Down Expand Up @@ -296,9 +295,7 @@ private Uri ImportNodeSet(UANodeSet model)
{
IUAModelContext _modelContext = model.ParseUAModelContext(m_NamespaceTable, m_TraceEvent.TraceEvent);
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage($"Entering AddressSpaceContext.ImportNodeSet - starting import {_modelContext.ModelUri}."));
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage("AddressSpaceContext.ImportNodeSet - the context for the imported model is created and starting import nodes."));
Dictionary<string, UANode> itemsDictionary = new Dictionary<string, UANode>();
//TODO Enhance/Improve node selection algorithm for ValidateAndExportModel #531
foreach (UANode node in model.Items)
{
if (itemsDictionary.ContainsKey(node.NodeId))
Expand Down Expand Up @@ -349,7 +346,12 @@ private void ValidateAndExportModel(int nameSpaceIndex)
IValidator validator = new Validator(this, m_TraceEvent);
//TODO Enhance/Improve node selection algorithm for ValidateAndExportModel #531
IEnumerable<IUANodeContext> _stubs = from _key in m_NodesDictionary.Values where _key.NodeIdContext.NamespaceIndex == nameSpaceIndex select _key;
List<IUANodeContext> _nodes = (from _node in _stubs where _node.UANode != null && (_node.UANode is UAType) select _node).ToList();
IEnumerable<IUANodeContext> undefindNodes = from _node in _stubs
where Object.ReferenceEquals(_node.UANode, null)
select _node;
foreach (IUANodeContext item in undefindNodes)
m_TraceEvent.TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeCannotBeNull, $"the node {item.ToString()} is not defined in the UANodeSet model"));
List <IUANodeContext> _nodes = (from _node in _stubs where _node.UANode != null && (_node.UANode is UAType) select _node).ToList();
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage($"Selected {_nodes.Count} types to be validated."));
IUANodeBase _objects = TryGetUANodeContext(UAInformationModel.ObjectIds.ObjectsFolder);
if (_objects is null)
Expand Down
4 changes: 2 additions & 2 deletions SemanticData/UANodeSetValidation/UANodeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public XmlQualifiedName ExportNodeBrowseName()
/// <param name="nodeFactory">The node container.</param>
/// <param name="validator">The validator.</param>
/// <exception cref="ArgumentNullException"><paramref name="nodeFactory"/> must not be null.</exception>
//TODO Add a warning that the AS contains nodes orphaned and inaccessible for browsing starting from the Root node #529
//TODO Import simple NodeSet2 file is incomplete #510
void IUANodeBase.CalculateNodeReferences(INodeFactory nodeFactory, IValidator validator)
{
Expand Down Expand Up @@ -332,7 +331,8 @@ public bool Equals(IUANodeBase other)

public override string ToString()
{
return $"NodeId={this.NodeIdContext}";
string browseName = this.UANode == null ? String.Empty : $", BrowseName = {this.UANode.BrowseName}";
return $"NodeId={this.NodeIdContext}{browseName}";
}

#endregion object
Expand Down

0 comments on commit 4842372

Please sign in to comment.