public static void CheckInvalidHashFunctionString() { string hashValue = null; PrimeHashingFamily hashFamily = new PrimeHashingFamily(1); Assert.Throws <ArgumentException>(() => hashFamily.Hash(hashValue, 1)); }
public static void CheckInvalidHashFunction() { int hashValue = "főzelék".GetHashCode(); PrimeHashingFamily hashFamily = new PrimeHashingFamily(1); Assert.Throws <ArgumentOutOfRangeException>(() => hashFamily.Hash(hashValue, 0)); }
public static void CheckHashIdenticalString() { PrimeHashingFamily hash1 = new PrimeHashingFamily(10); PrimeHashingFamily hash2 = new PrimeHashingFamily(10); string hashValue = "főzelék"; for (int i = 1; i < hash1.NumberOfFunctions; i++) { int result1 = hash1.Hash(hashValue, i); int result2 = hash2.Hash(hashValue, i); Assert.Equal(result1, result2); } }
public static void CheckHashIdenticalInt() { PrimeHashingFamily hash1 = new PrimeHashingFamily(5); PrimeHashingFamily hash2 = new PrimeHashingFamily(5); int hashValue = "főzelék".GetHashCode(); for (int i = 1; i < hash1.NumberOfFunctions; i++) { int result1 = hash1.Hash(hashValue, i); int result2 = hash2.Hash(hashValue, i); Assert.Equal(result1, result2); } }
public static void CheckInvalidHashConstruction() { PrimeHashingFamily hashFamily; Assert.Throws <ArgumentOutOfRangeException>(() => hashFamily = new PrimeHashingFamily(0)); }