From 531e53d1547a060ee14dd289c6f5b0745435ef82 Mon Sep 17 00:00:00 2001
From: "VKMTHD\\franzjosefkober" <franz.josef.kober@ivt.tugraz.at>
Date: Wed, 26 Jan 2022 17:18:38 +0100
Subject: [PATCH] added hash sort test case and test file for Angledrive

---
 .../Testdata/XML/Sort/Angledrive.xml          | 32 +++++++++++++++++++
 .../Testdata/XML/Sort/Angledrive_unsorted.xml | 32 +++++++++++++++++++
 .../VectoHashingTest/VectoHashSortTest.cs     | 11 ++++++-
 .../VectoHashingTest/VectoHashingTest.csproj  |  6 ++++
 4 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive.xml
 create mode 100644 VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive_unsorted.xml

diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive.xml
new file mode 100644
index 0000000000..f9c91c4285
--- /dev/null
+++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive.xml
@@ -0,0 +1,32 @@
+<?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:Angledrive xsi:type="v2.0:AngledriveComponentDeclarationType">
+        <v2.0:Data xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xsi:type="AngledriveDataDeclarationType" id="ANGL-asdf">           
+         <Manufacturer>Generic Vendor</Manufacturer>
+         <Model>Generic Model</Model>
+         <CertificationNumber>ANGL-1234</CertificationNumber>
+         <Date>2021-11-18T14:09:17.2810263Z</Date>
+         <AppVersion>aaaaa</AppVersion>
+         <Ratio>1.123</Ratio>
+         <CertificationMethod>Option 1</CertificationMethod>
+		<TorqueLossMap>
+			<Entry inputSpeed="0.00" inputTorque="-10000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="0.00" inputTorque="0.00" torqueLoss="10.00" />
+			<Entry inputSpeed="0.00" inputTorque="10000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="1000.00" inputTorque="-1000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="1000.00" inputTorque="0.00" torqueLoss="10.00" />
+			<Entry inputSpeed="1000.00" inputTorque="1000.00" torqueLoss="100.00" />
+		</TorqueLossMap>
+        </v2.0:Data>
+        <v2.0:Signature>
+            <di:Reference URI="#ANGL-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>FGaItzPcx1qGytVlroFp+PU9rzsaQWRWnxmIspkqCRM=</di:DigestValue>
+            </di:Reference>
+        </v2.0:Signature>
+    </tns:Angledrive>
+</tns:VectoInputDeclaration>
\ No newline at end of file
diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive_unsorted.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive_unsorted.xml
new file mode 100644
index 0000000000..a86d8cb6f7
--- /dev/null
+++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Angledrive_unsorted.xml
@@ -0,0 +1,32 @@
+<?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:Angledrive xsi:type="v2.0:AngledriveComponentDeclarationType">
+        <v2.0:Data xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xsi:type="AngledriveDataDeclarationType" id="ANGL-asdf">           
+         <Manufacturer>Generic Vendor</Manufacturer>
+         <Model>Generic Model</Model>
+         <CertificationNumber>ANGL-1234</CertificationNumber>
+         <Date>2021-11-18T14:09:17.2810263Z</Date>
+         <AppVersion>aaaaa</AppVersion>
+         <Ratio>1.123</Ratio>
+         <CertificationMethod>Option 1</CertificationMethod>
+		<TorqueLossMap>
+			<Entry inputSpeed="0.00" inputTorque="-10000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="1000.00" inputTorque="1000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="0.00" inputTorque="10000.00" torqueLoss="100.00" />
+			<Entry inputSpeed="0.00" inputTorque="0.00" torqueLoss="10.00" />
+			<Entry inputSpeed="1000.00" inputTorque="0.00" torqueLoss="10.00" />
+			<Entry inputSpeed="1000.00" inputTorque="-1000.00" torqueLoss="100.00" />
+		</TorqueLossMap>
+        </v2.0:Data>
+        <v2.0:Signature>
+            <di:Reference URI="#ANGL-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>FGaItzPcx1qGytVlroFp+PU9rzsaQWRWnxmIspkqCRM=</di:DigestValue>
+            </di:Reference>
+        </v2.0:Signature>
+    </tns:Angledrive>
+</tns:VectoInputDeclaration>
\ No newline at end of file
diff --git a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs
index 51847360ac..bb5fdccd02 100644
--- a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs
+++ b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs
@@ -74,7 +74,16 @@ namespace VectoHashingTest
 			Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.TorqueConverter));
 		}
 
-		
+
+		[TestCase("FGaItzPcx1qGytVlroFp+PU9rzsaQWRWnxmIspkqCRM=", @"Testdata\XML\Sort\Angledrive.xml"),
+		TestCase("FGaItzPcx1qGytVlroFp+PU9rzsaQWRWnxmIspkqCRM=", @"Testdata\XML\Sort\Angledrive_unsorted.xml")]
+		public void TestAngledriveComponentHashSort(string expectedHash, string filePath)
+		{
+			var loadedFile = VectoHash.Load(filePath);
+			Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.Angledrive));
+		}
+
+
 		[TestCase("NiyH2Xp0rQswwXIOf52Jm0wvK4Yc2/PL/T+zQCWQGFo=", @"Testdata\XML\Sort\ADC_unsorted.xml")]
 		public void TestADCHashSort(string expectedHash, string filePath)
 		{
diff --git a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj
index 432d50c21f..7035b7557b 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\Angledrive.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Testdata\XML\Sort\Angledrive_unsorted.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="Testdata\XML\Sort\Axlegear.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-- 
GitLab