Пример #1
0
        public void Same_before_and_after()
        {
            byte[] bytesA = new byte[32];
            new Random(42).NextBytes(bytesA);
            Hash32 a = new Hash32(bytesA);

            Assert.AreEqual(bytesA.ToHexString(true), a.ToString());
        }
Пример #2
0
        public void Diff_is_not_same()
        {
            byte[] bytesA = new byte[32];
            new Random(42).NextBytes(bytesA);
            byte[] bytesB = new byte[32];
            Hash32 a      = new Hash32(bytesA);
            Hash32 b      = new Hash32(bytesB);

            Assert.AreNotEqual(a, b);
            Assert.False(a.Equals(b));
            Assert.False(b.Equals(a));
            Assert.False(a == b);
            Assert.False(!(a != b));
            Assert.False(a.Equals((object)b));
            Assert.False(a.Equals(b));
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreNotEqual(a.ToString(), b.ToString());
        }
Пример #3
0
        public void Same_is_same()
        {
            byte[] bytesA = new byte[32];
            new Random(42).NextBytes(bytesA);
            byte[] bytesB = new byte[32];
            bytesA.AsSpan().CopyTo(bytesB);
            Hash32 a = new Hash32(bytesA);
            Hash32 b = new Hash32(bytesB);

            Assert.AreEqual(a, b);
            Assert.True(a.Equals(b));
            Assert.True(b.Equals(a));
            Assert.True(a == b);
            Assert.True(!(a != b));
            Assert.True(a.Equals((object)b));
            Assert.True(a.Equals(b));
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
            Assert.AreEqual(a.ToString(), b.ToString());
            Assert.AreEqual(0, a.CompareTo(b));
        }
Пример #4
0
 public Parameter(Hash32 hash)
 {
     Hash = hash.ToString();
 }