示例#1
0
        public void When_comparing_two_different_sub_arrays()
        {
            var srcArray = new[] { 1, 2, 3, 4, 5 };

            var subOne = new SubArray <int>(srcArray, 0, 3);
            var subTwo = new SubArray <int>(srcArray, 1, 3);

            subOne.Equals(subTwo).ShouldBeFalse();
            subOne.Equals((object)subTwo).ShouldBeFalse();

            (subOne == subTwo).ShouldBeFalse();
            (subOne != subTwo).ShouldBeTrue();

            subOne.GetHashCode().ShouldNotBe(subTwo.GetHashCode());
            subOne.ToString().ShouldNotBe(subTwo.ToString());
        }
示例#2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (SubArray != null ? SubArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntArray != null ? IntArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntIntArray != null ? IntIntArray.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Poco != null ? Poco.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (String != null ? String.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Dictionary != null ? Dictionary.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Delegate != null ? Delegate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TestEnum != null ? TestEnum.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Exception != null ? Exception.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ImmutableList != null ? ImmutableList.GetHashCode() : 0);
         return(hashCode);
     }
 }