diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear.xml new file mode 100644 index 0000000000000000000000000000000000000000..0e1d5a8c4d921cdf12225012334e79ca66364bf1 --- /dev/null +++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.10.1" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v2.10" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.3" xmlns:v2.6="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.6" xmlns:v2.10.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.10.1" xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent v:\VectoCore\VectoCore\Resources\XSD/VectoDeclarationComponent.xsd"> + <tns:Axlegear xsi:type="v2.0:AxlegearComponentDeclarationType"> + <v2.0:Data xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xsi:type="v2.0:AxlegearDataDeclarationType" id="AXL-asdf"> + <Manufacturer>Generic Vendor</Manufacturer> + <Model>Generic Model</Model> + <CertificationNumber>AXL-AXL_12</CertificationNumber> + <Date>2021-11-18T14:23:31.4958567Z</Date> + <AppVersion>VectoCore</AppVersion> + <LineType>Single portal axle</LineType> + <Ratio>1.000</Ratio> + <CertificationMethod>Measured</CertificationMethod> + <TorqueLossMap> + <Entry inputSpeed="0.00" inputTorque="-50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="0.00" inputTorque="-125.10" torqueLoss="5.10" /> + <Entry inputSpeed="0.00" inputTorque="0.10" torqueLoss="5.10" /> + <Entry inputSpeed="0.00" inputTorque="125.10" torqueLoss="5.10" /> + <Entry inputSpeed="0.00" inputTorque="50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="5000.00" inputTorque="-50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="5000.00" inputTorque="-780.10" torqueLoss="31.10" /> + <Entry inputSpeed="5000.00" inputTorque="0.10" torqueLoss="31.10" /> + <Entry inputSpeed="5000.00" inputTorque="780.10" torqueLoss="31.10" /> + <Entry inputSpeed="5000.00" inputTorque="50000.10" torqueLoss="2000.10" /> + </TorqueLossMap> + </v2.0:Data> + <v2.0:Signature> + <di:Reference URI="#AXL-asdf"> + <di:Transforms> + <di:Transform Algorithm="urn:vecto:xml:2017:canonicalization" /> + <di:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> + </di:Transforms> + <di:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> + <di:DigestValue>og41nROicUT1OoesUTZ9/uoroCUbqlTo7nKmCRYQap4=</di:DigestValue> + </di:Reference> + </v2.0:Signature> + </tns:Axlegear> +</tns:VectoInputDeclaration> \ No newline at end of file diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear_unsorted.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear_unsorted.xml new file mode 100644 index 0000000000000000000000000000000000000000..594370654f3c9c0e9d2ed6c35258b4bcf1f3c12d --- /dev/null +++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Axlegear_unsorted.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.10.1" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v2.10" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.3" xmlns:v2.6="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.6" xmlns:v2.10.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.10.1" xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent v:\VectoCore\VectoCore\Resources\XSD/VectoDeclarationComponent.xsd"> + <tns:Axlegear xsi:type="v2.0:AxlegearComponentDeclarationType"> + <v2.0:Data xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xsi:type="v2.0:AxlegearDataDeclarationType" id="AXL-asdf"> + <Manufacturer>Generic Vendor</Manufacturer> + <Model>Generic Model</Model> + <CertificationNumber>AXL-AXL_12</CertificationNumber> + <Date>2021-11-18T14:23:31.4958567Z</Date> + <AppVersion>VectoCore</AppVersion> + <LineType>Single portal axle</LineType> + <Ratio>1.000</Ratio> + <CertificationMethod>Measured</CertificationMethod> + <TorqueLossMap> + <Entry inputSpeed="0.00" inputTorque="50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="5000.00" inputTorque="-50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="0.00" inputTorque="-50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="0.00" inputTorque="125.10" torqueLoss="5.10" /> + <Entry inputSpeed="5000.00" inputTorque="780.10" torqueLoss="31.10" /> + <Entry inputSpeed="5000.00" inputTorque="50000.10" torqueLoss="2000.10" /> + <Entry inputSpeed="5000.00" inputTorque="-780.10" torqueLoss="31.10" /> + <Entry inputSpeed="5000.00" inputTorque="0.10" torqueLoss="31.10" /> + <Entry inputSpeed="0.00" inputTorque="-125.10" torqueLoss="5.10" /> + <Entry inputSpeed="0.00" inputTorque="0.10" torqueLoss="5.10" /> + </TorqueLossMap> + </v2.0:Data> + <v2.0:Signature> + <di:Reference URI="#AXL-asdf"> + <di:Transforms> + <di:Transform Algorithm="urn:vecto:xml:2017:canonicalization" /> + <di:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> + </di:Transforms> + <di:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> + <di:DigestValue>og41nROicUT1OoesUTZ9/uoroCUbqlTo7nKmCRYQap4=</di:DigestValue> + </di:Reference> + </v2.0:Signature> + </tns:Axlegear> +</tns:VectoInputDeclaration> \ No newline at end of file diff --git a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs index 6a20ac9c69545ca865a227e4aeb6d9c653fb5ddc..2a6f7c7c01801e3e9a5578c217a16a9fdc0f1a44 100644 --- a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs +++ b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs @@ -22,6 +22,12 @@ namespace VectoHashingTest xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } + [TestCase(@"Testdata\XML\Sort\Axlegear.xml")] + public void TestHash(string filePath) + { + var loadedFile = VectoHash.Load(filePath); + var hash = loadedFile.ComputeHash(VectoComponents.Axlegear); + } [TestCase("ttvMnXYdQrEAu47QEO2AKyfzOdPSlcdsR/MrmH/mX+k=", @"Testdata\XML\Sort\Engine.xml"), TestCase("ttvMnXYdQrEAu47QEO2AKyfzOdPSlcdsR/MrmH/mX+k=", @"Testdata\XML\Sort\Engine_unsorted.xml")] @@ -30,7 +36,25 @@ namespace VectoHashingTest var loadedFile = VectoHash.Load(filePath); Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.Engine)); } + + + [TestCase("hRzWfx3/El/LwEtP86Utm3dgBAF6CagrpEREsca7+/0=", @"Testdata\XML\Sort\Gearbox_APT-N_unsorted.xml"), + TestCase("XZCluPiG05mOAj5rTjTllCWbhCTEYVxCbE940ck3XsA=", @"Testdata\XML\Sort\Gearbox_IHPC_unsorted.xml"), + TestCase("LrsR3WfAkFia53dMiwGEIeAiA+9bdWvaS6x7dIL9yiQ=", @"Testdata\XML\Sort\Gearbox_FWD.xml"), + TestCase("LrsR3WfAkFia53dMiwGEIeAiA+9bdWvaS6x7dIL9yiQ=", @"Testdata\XML\Sort\Gearbox_FWD_unsorted.xml")] + public void TestGearboxComponentHashSort(string expectedHash, string filePath) + { + var loadedFile = VectoHash.Load(filePath); + Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.Gearbox)); + } + [TestCase("og41nROicUT1OoesUTZ9/uoroCUbqlTo7nKmCRYQap4=", @"Testdata\XML\Sort\Axlegear.xml"), + TestCase("og41nROicUT1OoesUTZ9/uoroCUbqlTo7nKmCRYQap4=", @"Testdata\XML\Sort\Axlegear_unsorted.xml")] + public void TestAxlegearComponentHashSort(string expectedHash, string filePath) + { + var loadedFile = VectoHash.Load(filePath); + Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.Axlegear)); + } [TestCase("NiyH2Xp0rQswwXIOf52Jm0wvK4Yc2/PL/T+zQCWQGFo=", @"Testdata\XML\Sort\ADC_unsorted.xml")] public void TestADCHashSort(string expectedHash, string filePath) @@ -63,16 +87,6 @@ namespace VectoHashingTest } - [TestCase("hRzWfx3/El/LwEtP86Utm3dgBAF6CagrpEREsca7+/0=", @"Testdata\XML\Sort\Gearbox_APT-N_unsorted.xml"), - TestCase("XZCluPiG05mOAj5rTjTllCWbhCTEYVxCbE940ck3XsA=", @"Testdata\XML\Sort\Gearbox_IHPC_unsorted.xml"), - TestCase("LrsR3WfAkFia53dMiwGEIeAiA+9bdWvaS6x7dIL9yiQ=", @"Testdata\XML\Sort\Gearbox_FWD.xml"), - TestCase("LrsR3WfAkFia53dMiwGEIeAiA+9bdWvaS6x7dIL9yiQ=", @"Testdata\XML\Sort\Gearbox_FWD_unsorted.xml")] - public void TestGearboxComponentHashSort(string expectedHash, string filePath) - { - var loadedFile = VectoHash.Load(filePath); - Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.Gearbox)); - } - [TestCase("3L/fYxKTdIwzADHQMnUBPxcNwZNEHM+sKEC2M32UnEA=", @"Testdata\XML\Sort\IEPC_1_unsorted.xml"), TestCase("BTHs/Hh2SgycIwU5OSuTgU/2SptMvmRFvPXr2X1Y7XQ=", @"Testdata\XML\Sort\IEPC_StdValues_unsorted.xml")] public void TestIEPCHashSort(string expectedHash, string filePath) diff --git a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj index 5ab0fefe58e2858281649366ad8cf1a845be62a8..0f7f557aa4766630e51594809efc80c8a02147d7 100644 --- a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj +++ b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj @@ -90,6 +90,12 @@ <Content Include="Testdata\XML\Sort\ADC_unsorted.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Content Include="Testdata\XML\Sort\Axlegear.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="Testdata\XML\Sort\Axlegear_unsorted.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="Testdata\XML\Sort\BatterySystem_1_unsorted.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content>