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);
// 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);