Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 4bdbb361 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding test for reading out existing hash

parent b4ede585
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,8 @@ namespace TUGraz.VectoHashing
public bool ValidateHash(VectoComponents component, int index = 0)
{
return StructuralComparisons.StructuralEqualityComparer.Equals(ReadHash(component), ComputeHash(component));
return StructuralComparisons.StructuralEqualityComparer.Equals(ReadHash(component, index),
ComputeHash(component, index));
}
private static string GetHashValue(XmlDocument hashed, string elementToHash)
......
......@@ -48,5 +48,25 @@ namespace VectoHashingTest
Assert.AreEqual(expectedHash, hash);
}
[TestCase(ReferenceXMLVehicle, VectoComponents.Engine, "e0c253b643f7f8f09b963aca4a264d06fbfa599f"),
TestCase(ReferenceXMLVehicle, VectoComponents.Gearbox, "d14189366134120e08fa3f2c6e3328dd13c08a23")]
public void TestReadHash(string file, VectoComponents component, string expectedHash)
{
var h = VectoHash.Load(file);
var existingHash = h.ReadHash(component);
Assert.AreEqual(expectedHash, existingHash);
}
[TestCase(ReferenceXMLVehicle, VectoComponents.Tyre, 0, "5074334bb2c090c5e258e9a664f5d19689a3f13d"),
TestCase(ReferenceXMLVehicle, VectoComponents.Tyre, 1, "6074334bb2c090c5e258e9a664f5d19689a3f13d")]
public void TestReadHashIdx(string file, VectoComponents component, int index, string expectedHash)
{
var h = VectoHash.Load(file);
var existingHash = h.ReadHash(component, index);
Assert.AreEqual(expectedHash, existingHash);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment