Skip to content

Commit

Permalink
Refactor XML validation into a class (#214)
Browse files Browse the repository at this point in the history
Previously, we only had a single static function that read the XML
schema on every XML validation. This change refactors the validation
into a separate class so that the schema does not have to be reloaded.

This is practical for validating a large number of XML samples.

We implement a table-driven test of the validation based on
the XML files directly extracted from the AASXs obtained from
http://admin-shell-io.com/samples/.

The tests revealed an inconsistency between our logic and "official"
AAS XSD schema. The problem could be fixed by "fixing" the XML and
moving the sequence of `AssetIdentificationModelRef` to the end of
XML serialization logic of an asset.
  • Loading branch information
mristin authored Oct 1, 2020
1 parent 3e2d6d8 commit 6247010
Show file tree
Hide file tree
Showing 26 changed files with 105,357 additions and 732 deletions.
31 changes: 31 additions & 0 deletions TestResult.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="0" runstate="Runnable" testcasecount="13" result="Passed" total="1" passed="1" failed="0" inconclusive="0" skipped="0" asserts="0" engine-version="3.11.1.0" clr-version="4.0.30319.42000" start-time="2020-09-29 08:11:39Z" end-time="2020-09-29 08:11:43Z" duration="3.657159">
<command-line><![CDATA["C:\MIHO\Develop\Aasx\aasx-package-explorer\tools\NUnit.ConsoleRunner.3.11.1\tools\nunit3-console.exe" artefacts/build/Debug/AasxCsharpLibrary.Tests.dll --test=AdminShellNS.Tests.TestLoadSaveChain.TestLoadSaveXmlValidate]]></command-line>
<filter>
<test>AdminShellNS.Tests.TestLoadSaveChain.TestLoadSaveXmlValidate</test>
</filter>
<test-suite type="Assembly" id="0-1018" name="AasxCsharpLibrary.Tests.dll" fullname="C:\MIHO\Develop\Aasx\aasx-package-explorer\artefacts\build\Debug\AasxCsharpLibrary.Tests.dll" runstate="Runnable" testcasecount="13" result="Passed" start-time="2020-09-29 08:11:40Z" end-time="2020-09-29 08:11:43Z" duration="2.386909" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="0">
<environment framework-version="3.12.0.0" clr-version="4.0.30319.42000" os-version="Microsoft Windows NT 10.0.17134.0" platform="Win32NT" cwd="C:\MIHO\Develop\Aasx\aasx-package-explorer" machine-name="CDE86488" user="miho" user-domain="FESTO" culture="de-DE" uiculture="de-DE" os-architecture="x64" />
<settings>
<setting name="DisposeRunners" value="True" />
<setting name="WorkDirectory" value="C:\MIHO\Develop\Aasx\aasx-package-explorer" />
<setting name="ImageRuntimeVersion" value="4.0.30319" />
<setting name="ImageTargetFrameworkName" value=".NETFramework,Version=v4.6.1" />
<setting name="ImageRequiresX86" value="False" />
<setting name="ImageRequiresDefaultAppDomainAssemblyResolver" value="False" />
<setting name="RuntimeFramework" value="net-4.0" />
<setting name="NumberOfTestWorkers" value="4" />
</settings>
<properties>
<property name="_PID" value="6440" />
<property name="_APPDOMAIN" value="domain-" />
</properties>
<test-suite type="TestSuite" id="0-1019" name="AdminShellNS" fullname="AdminShellNS" runstate="Runnable" testcasecount="13" result="Passed" start-time="2020-09-29 08:11:40Z" end-time="2020-09-29 08:11:43Z" duration="2.364843" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="0">
<test-suite type="TestSuite" id="0-1020" name="Tests" fullname="AdminShellNS.Tests" runstate="Runnable" testcasecount="13" result="Passed" start-time="2020-09-29 08:11:40Z" end-time="2020-09-29 08:11:43Z" duration="2.364241" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="0">
<test-suite type="TestFixture" id="0-1012" name="TestLoadSaveChain" fullname="AdminShellNS.Tests.TestLoadSaveChain" classname="AdminShellNS.Tests.TestLoadSaveChain" runstate="Runnable" testcasecount="2" result="Passed" start-time="2020-09-29 08:11:40Z" end-time="2020-09-29 08:11:43Z" duration="2.358844" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="0">
<test-case id="0-1015" name="TestLoadSaveXmlValidate" fullname="AdminShellNS.Tests.TestLoadSaveChain.TestLoadSaveXmlValidate" methodname="TestLoadSaveXmlValidate" classname="AdminShellNS.Tests.TestLoadSaveChain" runstate="Runnable" seed="2101435676" result="Passed" start-time="2020-09-29 08:11:40Z" end-time="2020-09-29 08:11:42Z" duration="2.342831" asserts="0" />
</test-suite>
</test-suite>
</test-suite>
</test-suite>
</test-run>
12 changes: 5 additions & 7 deletions src/AasxCsharpLibrary.Tests/AasxCsharpLibrary.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="TestAdminShellUtil.cs" />
<Compile Include="TestLoadSaveChain.cs" />
<Compile Include="TemporaryDirectory.cs" />
<Compile Include="TestValidateXml.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AasxCsharpLibrary\AasxCsharpLibrary.csproj">
Expand All @@ -70,12 +71,9 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\schemas\xml\AAS.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\schemas\xml\IEC61360.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="TestResources\XmlValidation\expectedOk\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand All @@ -85,4 +83,4 @@
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
</Project>
</Project>
Loading

0 comments on commit 6247010

Please sign in to comment.