Exemplo n.º 1
0
        public void GenerateHash64_ForDifferentStringInputs_ProducesDifferentOutputs()
        {
            var inputs = TestGuids.Get().Select(g => g.ToString()).ToArray();

            var outputs = inputs.Select(i => HashGenerator.GenerateHash64(i).ToString()).ToList();

            outputs.Distinct().Count().Should().Be(inputs.Length);
        }
Exemplo n.º 2
0
        public async Task GenerateHash64AndGenerateHash64Async_SameArrayOfBytes_ProduceTheSameHash()
        {
            var inputs = TestGuids.Get().Select(g => g.ToByteArray()).ToArray();

            foreach (var input in inputs)
            {
                var hash1 = HashGenerator.GenerateHash64(input);
                var hash2 = await HashGenerator.GenerateHash64Async(new MemoryStream(input));

                hash1.ToString().Should().Be(hash2.ToString());
            }
        }
Exemplo n.º 3
0
        public void GenerateHash64AndGenerateJsonHash64_SameSourceObject_ProduceTheSameHash()
        {
            var guids = TestGuids.Get();

            for (var i = 0; i < guids.Length; i++)
            {
                var obj = new TestClass {
                    A = i, B = new String(i.ToString()[0], i), C = guids[i]
                };

                var json  = JsonSerializer.Serialize(obj);
                var bytes = Encoding.ASCII.GetBytes(json);

                var bytesHash = HashGenerator.GenerateHash64(bytes);
                var jsonHash  = HashGenerator.GenerateJsonHash64(obj);

                jsonHash.AsInt64().Should().Be(bytesHash.AsInt64());
            }
        }
 public Hash64 GenerateHash64()
 {
     return(HashGenerator.GenerateHash64(InputSize == InputSize.OneKB ? _bytes_1KB : _bytes_1MB));
 }