mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
24 lines
698 B
C#
24 lines
698 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Octokit.Tests.Helpers
|
|
{
|
|
public class CollectionComparer<T> : IEqualityComparer<IReadOnlyCollection<T>>
|
|
{
|
|
public bool Equals(IReadOnlyCollection<T> x, IReadOnlyCollection<T> y)
|
|
{
|
|
if (ReferenceEquals(x, y)) return true;
|
|
if (ReferenceEquals(x, null)) return false;
|
|
if (ReferenceEquals(y, null)) return false;
|
|
if (x.GetType() != y.GetType()) return false;
|
|
|
|
return x.Count == y.Count && x.Intersect(y).Count() == x.Count();
|
|
}
|
|
|
|
public int GetHashCode(IReadOnlyCollection<T> obj)
|
|
{
|
|
return obj.Count;
|
|
}
|
|
}
|
|
}
|