예제 #1
0
        public void GetHashCode_UseSameAndDifferentValues_SameOrDifferentHashCodes()
        {
            StringWithQualityHeaderValue value1 = new StringWithQualityHeaderValue("t", 0.123);
            StringWithQualityHeaderValue value2 = new StringWithQualityHeaderValue("t", 0.123);
            StringWithQualityHeaderValue value3 = new StringWithQualityHeaderValue("T", 0.123);
            StringWithQualityHeaderValue value4 = new StringWithQualityHeaderValue("t");
            StringWithQualityHeaderValue value5 = new StringWithQualityHeaderValue("x", 0.123);
            StringWithQualityHeaderValue value6 = new StringWithQualityHeaderValue("t", 0.5);
            StringWithQualityHeaderValue value7 = new StringWithQualityHeaderValue("t", 0.1234);
            StringWithQualityHeaderValue value8 = new StringWithQualityHeaderValue("T");
            StringWithQualityHeaderValue value9 = new StringWithQualityHeaderValue("x");

            Assert.Equal(value1.GetHashCode(), value2.GetHashCode());
            Assert.Equal(value1.GetHashCode(), value3.GetHashCode());
            Assert.NotEqual(value1.GetHashCode(), value4.GetHashCode());
            Assert.NotEqual(value1.GetHashCode(), value5.GetHashCode());
            Assert.NotEqual(value1.GetHashCode(), value6.GetHashCode());
            Assert.NotEqual(value1.GetHashCode(), value7.GetHashCode());
            Assert.Equal(value4.GetHashCode(), value8.GetHashCode());
            Assert.NotEqual(value4.GetHashCode(), value9.GetHashCode());
        }