示例#1
0
        public void TestStringHashKey()
        {
            var hello1 = new MonkeyString {
                Value = "Hello world"
            };
            var hello2 = new MonkeyString {
                Value = "Hello world"
            };
            var diff1 = new MonkeyString {
                Value = "My name is johnny"
            };
            var diff2 = new MonkeyString {
                Value = "My name is johnny"
            };

            // General rule for every hashable types: object with same content
            // have different hash keys.
            Assert.Equal(hello1.HashKey(), hello2.HashKey());

            // General rule for every hashable type: object with same content
            // have different hash keys.
            Assert.Equal(diff1.HashKey(), diff2.HashKey());

            // General rule for every hashable type: object with different
            // content have same hash keys.
            Assert.NotEqual(hello1.HashKey(), diff1.HashKey());
        }
示例#2
0
        public void TestStringHashKey()
        {
            var hello1 = new MonkeyString {
                Value = "Hello World"
            };
            var hello2 = new MonkeyString {
                Value = "Hello World"
            };
            var diff1 = new MonkeyString {
                Value = "My name is johnny"
            };
            var diff2 = new MonkeyString {
                Value = "My name is johnny"
            };

            Assert.Equal(hello1.HashKey(), hello2.HashKey());
            Assert.Equal(diff1.HashKey(), diff2.HashKey());
            Assert.NotEqual(hello1.HashKey(), diff1.HashKey());
        }