Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Cleanup ImmutableArray tests #14798

Merged
merged 1 commit into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/Common/tests/System/Collections/DelegateEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace System.Collections.Tests
{
internal sealed class DelegateEqualityComparer<T> : IEqualityComparer<T>, IEqualityComparer
{
private readonly Func<T, T, bool> _equals;
private readonly Func<T, int> _getHashCode;
private readonly Func<object, object, bool> _objectEquals;
private readonly Func<object, int> _objectGetHashCode;

public DelegateEqualityComparer(
Func<T, T, bool> equals = null,
Func<T, int> getHashCode = null,
Func<object, object, bool> objectEquals = null,
Func<object, int> objectGetHashCode = null)
{
_equals = equals ?? ((x, y) => { throw new NotImplementedException(); });
_getHashCode = getHashCode ?? (obj => { throw new NotImplementedException(); });
_objectEquals = objectEquals ?? ((x, y) => { throw new NotImplementedException(); });
_objectGetHashCode = objectGetHashCode ?? (obj => { throw new NotImplementedException(); });
}

public bool Equals(T x, T y) => _equals(x, y);

public int GetHashCode(T obj) => _getHashCode(obj);

bool IEqualityComparer.Equals(object x, object y) => _objectEquals(x, y);

int IEqualityComparer.GetHashCode(object obj) => _objectGetHashCode(obj);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public bool IsEmpty
}

/// <summary>
/// Gets the number of array in the collection.
/// Gets the number of elements in the array.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int Length
Expand Down
Loading