private static void Mapper_Basics(ISanitizeMapper mapper) { // Verify mapper doesn't throw for min and max value and produces different values Assert.AreNotEqual(mapper.Generate(uint.MinValue), mapper.Generate(uint.MaxValue)); // Verify no collisions for 10k values (using a consistent seed for repeatability) Random r = new Random(0); HashSet <uint> hashes = new HashSet <uint>(); HashSet <string> results = new HashSet <string>(); while (hashes.Count < 10000) { // If the hash isn't a duplicate, verify the result isn't either uint hash = (uint)r.Next(); if (hashes.Add(hash)) { Assert.IsTrue(results.Add(mapper.Generate(hash)), $"Mapper {mapper.GetType().Name} produced collision for {hash}."); } } }
public MapColumnHandler(uint hashKeyHash, ISanitizeMapper mapper) { this.HashKeyHash = hashKeyHash; this.Mapper = mapper; this.Block = new String8Block(); }