public void ListsEqual()
        {
            var list1 = new List <int> {
                1
            };
            var list2a = new List <int> {
                1, 2
            };
            var list2b = new List <int> {
                1, 2
            };
            var list2c = new List <int> {
                1, 3
            };

            Assert.True(GaxEqualityHelpers.ListsEqual <int>(null, null));
            Assert.False(GaxEqualityHelpers.ListsEqual(list1, null));
            Assert.False(GaxEqualityHelpers.ListsEqual(null, list1));

            Assert.True(GaxEqualityHelpers.ListsEqual(list1, list1));
            Assert.True(GaxEqualityHelpers.ListsEqual(list2a, list2b));

            // This gets an "early out" due to the counts differing.
            Assert.False(GaxEqualityHelpers.ListsEqual(list1, list2a));
            // Here we have to actually iterate.
            Assert.False(GaxEqualityHelpers.ListsEqual(list2b, list2c));
        }
 /// <inheritdoc />
 public bool Equals(GrpcChannelOptions other) =>
 other is object &&
 EnableServiceConfigResolution == other.EnableServiceConfigResolution &&
 KeepAliveTime == other.KeepAliveTime &&
 PrimaryUserAgent == other.PrimaryUserAgent &&
 MaxSendMessageSize == other.MaxSendMessageSize &&
 MaxReceiveMessageSize == other.MaxReceiveMessageSize &&
 GaxEqualityHelpers.ListsEqual(CustomOptions, other.CustomOptions);
 /// <inheritdoc />
 public override int GetHashCode() =>
 GaxEqualityHelpers.CombineHashCodes(
     EnableServiceConfigResolution.GetHashCode(),
     KeepAliveTime.GetHashCode(),
     PrimaryUserAgent?.GetHashCode() ?? 0,
     MaxSendMessageSize.GetHashCode(),
     MaxReceiveMessageSize.GetHashCode(),
     GaxEqualityHelpers.GetListHashCode(CustomOptions));
 /// <inheritdoc />
 public override int GetHashCode() =>
 GaxEqualityHelpers.CombineHashCodes((int)ChangeType, OldIndex ?? -1, NewIndex ?? -1, Document.GetHashCode());
Esempio n. 5
0
 /// <inheritdoc />
 public override int GetHashCode() => GaxEqualityHelpers.CombineHashCodes(_seconds.GetHashCode(), _nanoseconds.GetHashCode());
Esempio n. 6
0
 public override int GetHashCode() =>
 GaxEqualityHelpers.CombineHashCodes(
     GrpcAdapter.GetHashCode(),
     Endpoint.GetHashCode(),
     Options.GetHashCode());
 public override int GetHashCode() =>
 GaxEqualityHelpers.CombineHashCodes(
     Endpoint.GetHashCode(),
     GaxEqualityHelpers.GetListHashCode(Options));
        // TODO: Consider making the equality and hash code methods smarter about not iterating
        // over Changes if we know that it's just autogenerated. (We'd need to keep a flag for that.)

        /// <summary>
        /// Compares this snapshot with another for equality. The documents and query are compared;
        /// the read time is not.
        /// </summary>
        /// <param name="other">The snapshot to compare this one with</param>
        /// <returns><c>true</c> if this snapshot is equal to <paramref name="other"/>; <c>false</c> otherwise.</returns>
        public bool Equals(QuerySnapshot other) =>
        other != null &&
        Query.Equals(other.Query) &&
        GaxEqualityHelpers.ListsEqual(Documents, other.Documents) &&
        GaxEqualityHelpers.ListsEqual(Changes, other.Changes);
 /// <inheritdoc />
 public override int GetHashCode() =>
 GaxEqualityHelpers.CombineHashCodes(Query.GetHashCode(), GaxEqualityHelpers.GetListHashCode(Documents), GaxEqualityHelpers.GetListHashCode(Changes));
 public void GetListHashCode_Null() =>
 Assert.Equal(0, GaxEqualityHelpers.GetListHashCode <string>(null));
 public void GetListHashCode_NotNull() =>
 CheckCombineHashCodes(4, array => GaxEqualityHelpers.GetListHashCode(array.ToList()));
 public void CombineHashCodes8() =>
 CheckCombineHashCodes(8, array => GaxEqualityHelpers.CombineHashCodes(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7]));
 public void CombineHashCodes5() =>
 CheckCombineHashCodes(5, array => GaxEqualityHelpers.CombineHashCodes(array[0], array[1], array[2], array[3], array[4]));
 public void CombineHashCodes3() =>
 CheckCombineHashCodes(3, array => GaxEqualityHelpers.CombineHashCodes(array[0], array[1], array[2]));
 /// <inheritdoc />
 public override int GetHashCode() => GaxEqualityHelpers.CombineHashCodes((int)Type, IntegerValue, Name.GetHashCode(), StringValue?.GetHashCode() ?? 0);
Esempio n. 16
0
 /// <inheritdoc />
 public override int GetHashCode() => GaxEqualityHelpers.CombineHashCodes(Latitude.GetHashCode(), Longitude.GetHashCode());