Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update models to harmonize with current UA-ModelCompiler release #658

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ public void AddressSpaceContextValidateAndExportModelOpcUa()
{
TracedAddressSpaceContext _asp = new TracedAddressSpaceContext();
((IAddressSpaceContext)_asp.AddressSpaceContext).ValidateAndExportModel(new Uri(UAInformationModel.Namespaces.OpcUa));
_asp.TestConsistency(1);
Assert.AreEqual<string>(BuildError.WrongReference2Property.Identifier, _asp.TraceList[0].BuildError.Identifier);
_asp.TestConsistency(0);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal void Clear()

public void TraceData(TraceEventType eventType, int id, object data)
{
throw new NotImplementedException($"{nameof(TraceData)} must not be used");
string message = $"TraceData eventType = {eventType}, id = {id}, {data}";
Console.WriteLine(message);
if (eventType == TraceEventType.Critical || eventType == TraceEventType.Error)
Expand All @@ -50,9 +51,10 @@ public void TraceData(TraceEventType eventType, int id, object data)
public void WriteTraceMessage(TraceMessage traceMessage)
{
Console.WriteLine(traceMessage.ToString());
if (traceMessage.BuildError.Focus == Focus.Diagnostic)
return;
Errors++;
if (traceMessage.BuildError.Focus != Focus.Diagnostic)
TraceList.Add(traceMessage);
TraceList.Add(traceMessage);
}

#endregion IBuildErrorsHandling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void UADataTypeTestMethod()
{
FileInfo _testDataFileInfo = new FileInfo(@"CorrectModels\DataTypeTest\DataTypeTest.NodeSet2.xml");
Assert.IsTrue(_testDataFileInfo.Exists);
List<IUANodeContext> _nodes = ValidateAndExportModelUnitTest(_testDataFileInfo, 18, new UriBuilder("http://cas.eu/UA/CommServer/UnitTests/DataTypeTest").Uri);
List<IUANodeContext> _nodes = ValidateAndExportModelUnitTest(_testDataFileInfo, 22, new UriBuilder("http://cas.eu/UA/CommServer/UnitTests/DataTypeTest").Uri);
Assert.IsFalse(_nodes.Where<IUANodeContext>(x => x.UANode == null).Any<IUANodeContext>());
Assert.AreEqual<int>(4, _nodes.Where<IUANodeContext>(x => x.UANode is UAType).Count<IUANodeContext>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public void ObjectEventNotifierOutOfRangeTestMethod()
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Count);
Assert.AreEqual<int>(2, _log.TraceList.Count);
Assert.AreEqual<string>(BuildError.WrongEventNotifier.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -50,10 +52,10 @@ public void WrongReference2PropertyTestMethod()
Assert.AreEqual<int>(1, _log.TraceList.Count());
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<int>(2, _log.TraceList.Count());
//TODO The exported model doesn't contain all nodes #653 review WrongReference2PropertyTestMethod
//Assert.AreEqual<string>(BuildError.WrongReference2Variable.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.WrongReference2Property.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -67,14 +69,15 @@ public void WrongValueRankTestMethod()
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(2, _log.TraceList.Count());
Assert.AreEqual<int>(3, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.WrongValueRank.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.WrongValueRank.Identifier, _log.TraceList[1].BuildError.Identifier);
Assert.AreEqual<string>(_log.TraceList[0].Message, _log.TraceList[1].Message); //Duplicated log entry
Assert.AreEqual<string>("The value -4 is not supported", _log.TraceList[0].Message);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[2].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -85,14 +88,14 @@ public void WrongAccessLevelTestMethod()
Assert.IsTrue(_testDataFileInfo.Exists);
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.IsTrue(_log.TraceList.Where<TraceMessage>(x => x.BuildError.Identifier == "P3-0506040000").Any<TraceMessage>());
Assert.AreEqual<int>(2, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.WrongAccessLevel.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -103,14 +106,16 @@ public void WrongInverseNameTestMethod()
Assert.IsTrue(_testDataFileInfo.Exists);
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(3, _log.TraceList.Count());
Assert.AreEqual(3, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Identifier == "P3-0503020000").Count<TraceMessage>());
Assert.AreEqual<int>(4, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.WrongInverseName.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.WrongInverseName.Identifier, _log.TraceList[1].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.WrongInverseName.Identifier, _log.TraceList[2].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[3].BuildError.Identifier);
}

[TestMethod]
Expand Down Expand Up @@ -138,14 +143,14 @@ public void WrongDisplayNameLength()
Assert.IsTrue(_testDataFileInfo.Exists);
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Count);
Assert.IsTrue(_log.TraceList.Where<TraceMessage>(x => x.BuildError.Identifier == "P3-0502050000").Any<TraceMessage>());
Assert.AreEqual<int>(2, _log.TraceList.Count);
Assert.AreEqual<string>(BuildError.WrongDisplayNameLength.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -156,14 +161,15 @@ public void WrongWriteMaskValue()
Assert.IsTrue(_testDataFileInfo.Exists);
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(2, _log.TraceList.Count);
Assert.AreEqual<int>(2, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Identifier == BuildError.WrongWriteMaskValue.Identifier).Count<TraceMessage>());
Assert.AreEqual<int>(3, _log.TraceList.Count);
Assert.AreEqual<string>(BuildError.WrongWriteMaskValue.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.WrongWriteMaskValue.Identifier, _log.TraceList[1].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[2].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -174,10 +180,8 @@ public void NotSupportedFeature()
Assert.IsTrue(_testDataFileInfo.Exists);
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
Assert.IsNotNull(_as);
Assert.IsNotNull(_as);
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Expand All @@ -198,8 +202,9 @@ public void WrongBrowseName()
Assert.AreEqual<string>(BuildError.EmptyBrowseName.Identifier, _log.TraceList[1].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(2, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<string>(BuildError.WrongSymbolicName.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -211,11 +216,13 @@ public void WrongNodeId()
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<int>(2, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.NodeIdNotDefined.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -227,11 +234,14 @@ public void UndefinedHasSubtypeTestMethod()
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
//Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<int>(2, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.UndefinedHasSubtypeTarget.Identifier, _log.TraceList[0].BuildError.Identifier);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[1].BuildError.Identifier);
}

[TestMethod]
Expand All @@ -243,12 +253,12 @@ public void UndefinedHasTypeDefinitionTestMethod()
TracedAddressSpaceContext _log = new TracedAddressSpaceContext();
IAddressSpaceContext _as = _log.AddressSpaceContext;
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(0, _log.TraceList.Count());
//TODO Recognize problems with P3.7.13 HasTypeDefinition ReferenceType #39
Assert.Inconclusive("Instances are not imported - the error is not recognized.");
Assert.AreEqual<int>(3, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
Assert.AreEqual<int>(1, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Identifier == "P3-0713000000").Count<TraceMessage>());
}

/// <summary>
Expand All @@ -264,13 +274,15 @@ public void UndefinedHasComponentTargetTestMethod()
IAddressSpaceContext _as = _log.AddressSpaceContext;
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(1, _log.TraceList.Count());
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, _log.TraceList[0].BuildError.Identifier);
_log.Clear();
_as.ValidateAndExportModel(m_NameSpace);
Assert.AreEqual<int>(4, _log.TraceList.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
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);
Assert.AreEqual<string>(BuildError.NonCategorized.Identifier, _log.TraceList[4].BuildError.Identifier);
}

#endregion TestMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void NameInheritedFrom0Test()
Assert.AreEqual<int>(0, traceContext.TraceList.Count);
traceContext.Clear();
addressSpace.ValidateAndExportModel(new UriBuilder("http://tricycleTypeV1").Uri);
Assert.AreEqual<int>(1, traceContext.TraceList.Count);
Assert.AreEqual<int>(2, traceContext.TraceList.Count);
IEnumerable<NodeFactoryBase> nodes = testingModelFixture.Export();
Assert.AreEqual(3, nodes.Count<NodeFactoryBase>());
Dictionary<string, NodeFactoryBase> nodesDictionary = nodes.ToDictionary<NodeFactoryBase, string>(x => x.SymbolicName.Name);
Expand Down Expand Up @@ -99,7 +99,7 @@ public void eoursel510Test()
Assert.AreEqual<int>(0, traceContext.TraceList.Count);
traceContext.Clear();
addressSpace.ValidateAndExportModel(new UriBuilder("http://tricycleTypeV1").Uri);
Assert.AreEqual<int>(4, traceContext.TraceList.Count);
Assert.AreEqual<int>(5, traceContext.TraceList.Count);
IEnumerable<NodeFactoryBase> nodes = testingModelFixture.Export();
Assert.AreEqual(22, nodes.Count<NodeFactoryBase>());
Dictionary<string, NodeFactoryBase> nodesDictionary = nodes.ToDictionary<NodeFactoryBase, string>(x => x.SymbolicName.Name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//__________________________________________________________________________________________________
//
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
// Copyright (C) 2022, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GitHub: https://github.com/mpostol/OPC-UA-OOI/discussions
//__________________________________________________________________________________________________
Expand Down Expand Up @@ -50,13 +50,14 @@ public void WriteTraceMessage(TraceMessage traceMessage)
{
Debug.WriteLine(traceMessage.ToString());
if (traceMessage.BuildError.Focus == Focus.Diagnostic)
Errors++;
else
TraceList.Add(traceMessage);
return;
Errors++;
TraceList.Add(traceMessage);
}

public void TraceData(TraceEventType eventType, int id, object data)
{
throw new NotImplementedException("It is intentionally not implemented");
if ((eventType == TraceEventType.Verbose) || (eventType == TraceEventType.Information))
Errors++;
else
Expand Down
Loading