예제 #1
0
        public void GetHashCodeTest()
        {
            var r = new Register16(10);

            Assert.Equal(r.GetHashCode(), new Register16(10).GetHashCode());
            Assert.NotEqual(r.GetHashCode(), new Register16(20).GetHashCode());
        }
예제 #2
0
        public void EqualityTest(ushort value)
        {
            var r1 = new Register16(value);
            var r2 = new Register16((ushort)(value / 2 - 1));
            var r3 = new Register16(value);

            Assert.True(r1 == r3);
            Assert.True(r1 != r2);
            Assert.True(r2 != r3);

            Assert.True(r1.Equals(r3));
            Assert.False(r1.Equals(r2));
            Assert.False(r2.Equals(r3));

            Assert.True(r1.Equals((object)r3));
            Assert.False(r1.Equals((object)r2));
            Assert.False(r2.Equals((object)r3));

            Assert.Equal(r1.GetHashCode(), r3.GetHashCode());
        }