From a5f13e7d3be477516c2a28f9936b63eed153b205 Mon Sep 17 00:00:00 2001 From: "VKMTHD\\franzjosefkober" <franz.josef.kober@ivt.tugraz.at> Date: Tue, 15 Feb 2022 17:12:28 +0100 Subject: [PATCH] added sort test case for TrailerAerodynamicDevice --- .../VectoCommon/Hashing/VectoComponents.cs | 7 +++- .../Resources/XMLNames.Designer.cs | 9 +++++ .../VectoCommon/Resources/XMLNames.resx | 3 ++ .../Sorted/TrailerAerodynamicDevice.xml | 34 +++++++++++++++++++ .../Unsorted/TrailerAerodynamicDevice.xml | 34 +++++++++++++++++++ .../VectoHashingTest/VectoHashSortTest.cs | 13 +++++-- .../VectoHashingTest/VectoHashingTest.csproj | 6 ++++ 7 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Sorted/TrailerAerodynamicDevice.xml create mode 100644 VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Unsorted/TrailerAerodynamicDevice.xml diff --git a/VectoCommon/VectoCommon/Hashing/VectoComponents.cs b/VectoCommon/VectoCommon/Hashing/VectoComponents.cs index cf4150dab2..f825f89aa1 100644 --- a/VectoCommon/VectoCommon/Hashing/VectoComponents.cs +++ b/VectoCommon/VectoCommon/Hashing/VectoComponents.cs @@ -53,7 +53,8 @@ namespace TUGraz.VectoCommon.Hashing CapacitorSystem, ElectricMachineSystem, IEPC, - ADC + ADC, + CertifiedAeroReduction } public static class VectoComponentsExtensionMethods @@ -97,6 +98,8 @@ namespace TUGraz.VectoCommon.Hashing return XMLNames.Component_IEPC; case VectoComponents.ADC: return XMLNames.Component_ADC; + case VectoComponents.CertifiedAeroReduction: + return XMLNames.Component_CertifiedAeroReduction; default: throw new ArgumentOutOfRangeException("VectoComponents", component, null); } @@ -141,6 +144,8 @@ namespace TUGraz.VectoCommon.Hashing return "IEPC-"; case VectoComponents.ADC: return "ADC-"; + case VectoComponents.CertifiedAeroReduction: + return "AERO-"; default: throw new ArgumentOutOfRangeException("VectoComponents", component, null); } diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs index 5800ec7894..3d834ede7d 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs +++ b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs @@ -1554,6 +1554,15 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to CertifiedAeroReduction. + /// </summary> + public static string Component_CertifiedAeroReduction { + get { + return ResourceManager.GetString("Component_CertifiedAeroReduction", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to Creator. /// </summary> diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.resx b/VectoCommon/VectoCommon/Resources/XMLNames.resx index 1663d19990..8aa653f6d3 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.resx +++ b/VectoCommon/VectoCommon/Resources/XMLNames.resx @@ -1878,4 +1878,7 @@ <data name="Component_IEPC" xml:space="preserve"> <value>IEPC</value> </data> + <data name="Component_CertifiedAeroReduction" xml:space="preserve"> + <value>CertifiedAeroReduction</value> + </data> </root> \ No newline at end of file diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Sorted/TrailerAerodynamicDevice.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Sorted/TrailerAerodynamicDevice.xml new file mode 100644 index 0000000000..e56c873e89 --- /dev/null +++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Sorted/TrailerAerodynamicDevice.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.7" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" +xmlns:v2.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" xmlns:v2.2="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.2" +xmlns:v2.7="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:DEV:v2.7" + 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:CertifiedAeroReduction > + <Data xsi:type="CertifiedAeroDataDeclarationType" id="AERO-asdf"> + <Manufacturer>Generic Manufacturer</Manufacturer> + <Model>Generic Tyre Model</Model> + <CertificationNumber>e12*0815/8051*2017/05T0000*00</CertificationNumber> + <Date>2017-02-15T11:00:00Z</Date> + <CertifiedAerodynamicReduction0>1.00</CertifiedAerodynamicReduction0> + <CertifiedAerodynamicReduction3>2.00</CertifiedAerodynamicReduction3> + <CertifiedAerodynamicReduction6>3.00</CertifiedAerodynamicReduction6> + <CertifiedAerodynamicReduction9>4.00</CertifiedAerodynamicReduction9> + <ApplicableVehicleGroups> + <ApplicableVehicleGroup>1123</ApplicableVehicleGroup> + <ApplicableVehicleGroup>2356</ApplicableVehicleGroup> + <ApplicableVehicleGroup>4356</ApplicableVehicleGroup> + </ApplicableVehicleGroups> + </Data> + <Signature> + <di:Reference URI="#AERO-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>3YVNlu+1souB/4IwePLPoBwhiJormfqMNRxQaZ75wvM=</di:DigestValue> + </di:Reference> + </Signature> + </tns:CertifiedAeroReduction> +</tns:VectoInputDeclaration> diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Unsorted/TrailerAerodynamicDevice.xml b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Unsorted/TrailerAerodynamicDevice.xml new file mode 100644 index 0000000000..9c42d57627 --- /dev/null +++ b/VectoCommon/VectoHashingTest/Testdata/XML/Sort/Component/Unsorted/TrailerAerodynamicDevice.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.7" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" +xmlns:v2.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" xmlns:v2.2="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.2" +xmlns:v2.7="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:DEV:v2.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:DEV:v2.7" + 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:CertifiedAeroReduction > + <Data xsi:type="CertifiedAeroDataDeclarationType" id="AERO-asdf"> + <Manufacturer>Generic Manufacturer</Manufacturer> + <Model>Generic Tyre Model</Model> + <CertificationNumber>e12*0815/8051*2017/05T0000*00</CertificationNumber> + <Date>2017-02-15T11:00:00Z</Date> + <CertifiedAerodynamicReduction0>1.00</CertifiedAerodynamicReduction0> + <CertifiedAerodynamicReduction3>2.00</CertifiedAerodynamicReduction3> + <CertifiedAerodynamicReduction6>3.00</CertifiedAerodynamicReduction6> + <CertifiedAerodynamicReduction9>4.00</CertifiedAerodynamicReduction9> + <ApplicableVehicleGroups> + <ApplicableVehicleGroup>4356</ApplicableVehicleGroup> + <ApplicableVehicleGroup>1123</ApplicableVehicleGroup> + <ApplicableVehicleGroup>2356</ApplicableVehicleGroup> + </ApplicableVehicleGroups> + </Data> + <Signature> + <di:Reference URI="#AERO-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>3YVNlu+1souB/4IwePLPoBwhiJormfqMNRxQaZ75wvM=</di:DigestValue> + </di:Reference> + </Signature> + </tns:CertifiedAeroReduction> +</tns:VectoInputDeclaration> diff --git a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs index a87b9df60d..8e0c36bbb9 100644 --- a/VectoCommon/VectoHashingTest/VectoHashSortTest.cs +++ b/VectoCommon/VectoHashingTest/VectoHashSortTest.cs @@ -24,11 +24,11 @@ namespace VectoHashingTest xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } - [TestCase(@"Testdata\XML\Sort\Axlegear.xml")] + [TestCase(SortedComponentPath + "TrailerAerodynamicDevice.xml")] public void TestHash(string filePath) { var loadedFile = VectoHash.Load(filePath); - var hash = loadedFile.ComputeHash(VectoComponents.Axlegear); + var hash = loadedFile.ComputeHash(VectoComponents.CertifiedAeroReduction); } [TestCase("ttvMnXYdQrEAu47QEO2AKyfzOdPSlcdsR/MrmH/mX+k=", SortedComponentPath + "Engine.xml"), @@ -134,5 +134,14 @@ namespace VectoHashingTest var loadedFile = VectoHash.Load(filePath); Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.IEPC)); } + + [TestCase("3YVNlu+1souB/4IwePLPoBwhiJormfqMNRxQaZ75wvM=", SortedComponentPath + "TrailerAerodynamicDevice.xml"), + TestCase("3YVNlu+1souB/4IwePLPoBwhiJormfqMNRxQaZ75wvM=", UnsortedComponentPath + "TrailerAerodynamicDevice.xml")] + public void TestTrailerAerodynamicDeviceSort(string expectedHash, string filePath) + { + var loadedFile = VectoHash.Load(filePath); + Assert.AreEqual(expectedHash, loadedFile.ComputeHash(VectoComponents.CertifiedAeroReduction)); + } + } } diff --git a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj index 7a23a60d72..4b7926d5a0 100644 --- a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj +++ b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj @@ -114,6 +114,9 @@ <Content Include="Testdata\XML\Sort\Component\Sorted\IEPC_StdValues.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Content Include="Testdata\XML\Sort\Component\Sorted\TrailerAerodynamicDevice.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="Testdata\XML\Sort\Component\Unsorted\ADC.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> @@ -183,6 +186,9 @@ <Content Include="Testdata\XML\Sort\Component\Unsorted\TorqueConverter.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Content Include="Testdata\XML\Sort\Component\Unsorted\TrailerAerodynamicDevice.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="Testdata\XML\ToHash\multiple_components.xml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> -- GitLab