Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert.Equal for sets and a custom Func comparer throws NotImplementedException #2804

Closed
AndriySvyryd opened this issue Oct 25, 2023 · 1 comment

Comments

@AndriySvyryd
Copy link

[Fact]
public void Test()
{
    Assert.Equal(new HashSet<int> { 1 }, new HashSet<int> { 1 }, AreEqual);

    static bool AreEqual(int x, int y) => true;
}

throws

Message: 
System.NotImplementedException : The method or operation is not implemented.
Stack Trace: 
HashSet1.AddIfNotPresent(T value, Int32& location) HashSet1.UnionWith(IEnumerable1 other) HashSet1.ctor(IEnumerable1 collection, IEqualityComparer1 comparer)
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Surprisingly, this doesn't throw:

[Fact]
public void Test()
{
    Assert.Equal(new HashSet<int> { 1 }, new HashSet<int> { 1 }, (x, y) => true);
}

V2.5.3

@bradwilson
Copy link
Member

Available in v2: 2.5.4-pre.7
Available in v3: 0.1.1-pre.301

ViktorHofer added a commit to v-wuzhai/arcade that referenced this issue Nov 14, 2023
…b0..cb1e33ba6

cb1e33ba6 Updated doc comment for AllException.ForFailures
5986aa7bf Remove all ValueTask support
e48a30666 Performance optimization: unused code in comparison hot path
094b4d4cf Formatting
b3e3c931a Performance improvements in CollectionTrackerExtensions.AsTracker
6a94a86a0 Performance improvements in AssertEqualityComparer (conditional IEquatable<Y> and IComparable<Y> with type caching)
f1843557b Replace dictionary with ring buffer in CollectionTracker.Enumerator
3bb330972 Don't depend on the Assert class inside AssertEqualityComparer
10f8fe362 Ensure all throws of NotImplementedException contain messages
37e83a858 Ensure all GetHashCode functions are implemented (xunit/xunit#2804)
4828bf193 xunit/xunit#2803: Add support for KeyValuePair<,> in AssertEqualityComparer to enable collections in values
a92673b02 xunit/xunit#2800: Record exceptions from Assert.(Not)Equal comparer
ba2525400 Replace concatenation and interpolation with String.Format

git-subtree-dir: src/Microsoft.DotNet.XUnitAssert/src
git-subtree-split: cb1e33ba612d4829e0848a44bde1026f5f9e3576
ViktorHofer added a commit to v-wuzhai/arcade that referenced this issue Nov 14, 2023
…b0..cb1e33ba6

cb1e33ba6 Updated doc comment for AllException.ForFailures
5986aa7bf Remove all ValueTask support
e48a30666 Performance optimization: unused code in comparison hot path
094b4d4cf Formatting
b3e3c931a Performance improvements in CollectionTrackerExtensions.AsTracker
6a94a86a0 Performance improvements in AssertEqualityComparer (conditional IEquatable<Y> and IComparable<Y> with type caching)
f1843557b Replace dictionary with ring buffer in CollectionTracker.Enumerator
3bb330972 Don't depend on the Assert class inside AssertEqualityComparer
10f8fe362 Ensure all throws of NotImplementedException contain messages
37e83a858 Ensure all GetHashCode functions are implemented (xunit/xunit#2804)
4828bf193 xunit/xunit#2803: Add support for KeyValuePair<,> in AssertEqualityComparer to enable collections in values
a92673b02 xunit/xunit#2800: Record exceptions from Assert.(Not)Equal comparer
ba2525400 Replace concatenation and interpolation with String.Format

git-subtree-dir: src/Microsoft.DotNet.XUnitAssert/src
git-subtree-split: cb1e33ba612d4829e0848a44bde1026f5f9e3576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants