public void GetHashCode_UseSameAndDifferentRanges_SameOrDifferentHashCodes()
        {
            ContentRangeHeaderValue range1 = new ContentRangeHeaderValue(1, 2, 5);
            ContentRangeHeaderValue range2 = new ContentRangeHeaderValue(1, 2);
            ContentRangeHeaderValue range3 = new ContentRangeHeaderValue(5);
            ContentRangeHeaderValue range4 = new ContentRangeHeaderValue(1, 2, 5);

            range4.Unit = "BYTES";
            ContentRangeHeaderValue range5 = new ContentRangeHeaderValue(1, 2, 5);

            range5.Unit = "myunit";

            Assert.NotEqual(range1.GetHashCode(), range2.GetHashCode()); // "bytes 1-2/5 vs. bytes 1-2/*"
            Assert.NotEqual(range1.GetHashCode(), range3.GetHashCode()); // "bytes 1-2/5 vs. bytes */5"
            Assert.NotEqual(range2.GetHashCode(), range3.GetHashCode()); // "bytes 1-2/* vs. bytes */5"
            Assert.Equal(range1.GetHashCode(), range4.GetHashCode());    // "bytes 1-2/5 vs. BYTES 1-2/5"
            Assert.NotEqual(range1.GetHashCode(), range5.GetHashCode()); // "bytes 1-2/5 vs. myunit 1-2/5"
        }
Example #2
0
    public void GetHashCode_UseSameAndDifferentRanges_SameOrDifferentHashCodes()
    {
        var range1 = new ContentRangeHeaderValue(1, 2, 5);
        var range2 = new ContentRangeHeaderValue(1, 2);
        var range3 = new ContentRangeHeaderValue(5);
        var range4 = new ContentRangeHeaderValue(1, 2, 5);

        range4.Unit = "BYTES";
        var range5 = new ContentRangeHeaderValue(1, 2, 5);

        range5.Unit = "myunit";

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