GetHashCode() 공개 메소드

public GetHashCode ( ) : int
리턴 int
예제 #1
0
        public void GetHashCode_UseSameAndDifferentRanges_SameOrDifferentHashCodes()
        {
            RangeHeaderValue range1 = new RangeHeaderValue(1, 2);
            RangeHeaderValue range2 = new RangeHeaderValue(1, 2);
            range2.Unit = "BYTES";
            RangeHeaderValue range3 = new RangeHeaderValue(1, null);
            RangeHeaderValue range4 = new RangeHeaderValue(null, 2);
            RangeHeaderValue range5 = new RangeHeaderValue();
            range5.Ranges.Add(new RangeItemHeaderValue(1, 2));
            range5.Ranges.Add(new RangeItemHeaderValue(3, 4));
            RangeHeaderValue range6 = new RangeHeaderValue();
            range6.Ranges.Add(new RangeItemHeaderValue(3, 4)); // reverse order of range5
            range6.Ranges.Add(new RangeItemHeaderValue(1, 2));

            Assert.Equal(range1.GetHashCode(), range2.GetHashCode());
            Assert.NotEqual(range1.GetHashCode(), range3.GetHashCode());
            Assert.NotEqual(range1.GetHashCode(), range4.GetHashCode());
            Assert.NotEqual(range1.GetHashCode(), range5.GetHashCode());
            Assert.Equal(range5.GetHashCode(), range6.GetHashCode());
        }