Skip to content

Commit

Permalink
ADI model from Embedded example import fails #509
Browse files Browse the repository at this point in the history
- added test to investigate the problem.
  • Loading branch information
mpostol committed Feb 8, 2021
1 parent b5b898a commit 0437afd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<Visible>False</Visible>
</AdditionalFiles>
<Compile Include="UANodeContextUnitTest.cs" />
<Compile Include="XMLModelsProblemsToReportUnitTest.cs" />
<Compile Include="XMLModelsCorrectModelsUnitTest.cs" />
<Compile Include="XMLModelsModelsWithErrorsUnitTest.cs" />
<Compile Include="XMLUANodeUnitTest.cs" />
Expand Down Expand Up @@ -136,7 +137,9 @@
<Content Include="XMLModels\ModelsWithErrors\UndefinedHasTypeDefinition.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="XMLModels\ProblemsToReport\ADI#509\Opc.Ua.Adi.NodeSet2.xml" />
<None Include="XMLModels\ProblemsToReport\ADI#509\Opc.Ua.Adi.NodeSet2.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="XMLModels\ProblemsToReport\eoursel510\Opc.Ua.NodeSet2.TriCycleType_V1.1.xml" />
<Content Include="XMLModels\ProblemsToReport\fgolra177\Opc.Ua.Semi.NodeSet2.xml" />
<Content Include="XMLModels\ProblemsToReport\fgolra177\OpcUaGemModel.xml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//___________________________________________________________________________________
//
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using UAOOI.SemanticData.BuildingErrorsHandling;

namespace UAOOI.SemanticData.UANodeSetValidation
{
[TestClass]
[DeploymentItem(@"XMLModels\ProblemsToReport", @"ProblemsToReport\")]
public class XMLModelsProblemsToReportUnitTest
{
[TestMethod]
public void ADITest()
{
FileInfo _testDataFileInfo = new FileInfo(@"ProblemsToReport\ADI#509\Opc.Ua.Adi.NodeSet2.xml");
Assert.IsTrue(_testDataFileInfo.Exists);
List<TraceMessage> _trace = new List<TraceMessage>();
IAddressSpaceContext _as = new AddressSpaceContext(z => _trace.Add(z));
_as.ImportUANodeSet(_testDataFileInfo);
Assert.AreEqual<int>(0, _trace.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic).Count<TraceMessage>());
_as.ValidateAndExportModel(@"http://opcfoundation.org/UA/ADI/");
IEnumerable<TraceMessage> vitalMessageserrors = _trace.Where<TraceMessage>(x => x.BuildError.Focus != Focus.Diagnostic);
IEnumerable<TraceMessage> focusNodeClass = _trace.Where<TraceMessage>(x => x.BuildError.Focus == Focus.NodeClass);
Assert.IsFalse(focusNodeClass.Where<TraceMessage>(x => !x.BuildError.Identifier.Trim().Contains("P3-0502020001")).Any<TraceMessage>());

//Assert.Inconclusive("The import returns unexpected errors.");

Assert.AreEqual<int>(5, vitalMessageserrors.Count<TraceMessage>());

Assert.AreEqual<int>(3, focusNodeClass.Count<TraceMessage>());
Debug.WriteLine(nameof(Focus.NodeClass));
foreach (TraceMessage item in focusNodeClass)
Debug.WriteLine(item.ToString());

IEnumerable<TraceMessage> focusNonCategorized = _trace.Where<TraceMessage>(x => x.BuildError.Focus == Focus.NonCategorized);
Assert.AreEqual<int>(2, focusNonCategorized.Count<TraceMessage>());
Debug.WriteLine(nameof(Focus.NonCategorized));
foreach (TraceMessage item in focusNonCategorized)
Debug.WriteLine(item.ToString());
}
}
}

0 comments on commit 0437afd

Please sign in to comment.