Beispiel #1
0
        public void MassiveCallToGetHashCodeOfLargeBytesArray()
        {
            var items = new My_ReadonlyBytes(Enumerable.Repeat((byte)6, 100000).ToArray());
            var hash  = items.GetHashCode();

            for (int i = 0; i < 100000; i++)
            {
                Assert.AreEqual(hash, items.GetHashCode());
            }
        }
Beispiel #2
0
        public void HashCode()
        {
            Assert.AreEqual(new My_ReadonlyBytes().GetHashCode(), new My_ReadonlyBytes().GetHashCode());
            Assert.AreEqual(new My_ReadonlyBytes(1, 2, 3).GetHashCode(), new My_ReadonlyBytes(1, 2, 3).GetHashCode());
            Assert.AreNotEqual(new My_ReadonlyBytes(1, 2, 3).GetHashCode(), new My_ReadonlyBytes(1, 2, 3, 4).GetHashCode());
            Assert.AreNotEqual(new My_ReadonlyBytes(1, 2, 3).GetHashCode(), new My_ReadonlyBytes(1, 2, 4).GetHashCode());
            Assert.AreNotEqual(new My_ReadonlyBytes(1, 2, 3).GetHashCode(), new My_ReadonlyBytes(1, 2).GetHashCode());
            Assert.AreNotEqual(new My_ReadonlyBytes(1, 2, 3).GetHashCode(), new My_ReadonlyBytes(3, 2, 1).GetHashCode());
            Assert.AreNotEqual(new My_ReadonlyBytes(1, 0).GetHashCode(), new My_ReadonlyBytes(0, 31).GetHashCode());

            var items = new My_ReadonlyBytes(4, 2, 67, 1);

            Assert.AreEqual(items.GetHashCode(), items.GetHashCode());
        }