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
Allow using an IEqualityComparer in BeEquivalentTo #1236
Comments
I like the second one the most. public static void Using<T, TComparer>()
where TComparer : IEqualityComparer<T>
{
} or public static void Using<T>(IEqualityComparer<T> comparer)
{
} I'm not sure what the signature of the first one would be? public static void Using<TComparer>()
where TComparer : IEqualityComparer
{
} I dislike that as:
In general I'd like to take Fluent Assertions to a more generic world. |
I really like this idea! Agree with @jnyrup that the second is more generic and clearer. I've been struggling with comparing types in a homegrown library to C# types. Using the DifferentObjectsEquivalencyStep approach I found on SO has been successful up to a point. |
We should support both passing a generic type as well as a generic instance. So two overloads. |
public static void Using<T, TComparer>()
where TComparer : IEqualityComparer<T>, new() This should probably have a It would be great to have an option to use a custom comparer with Fluent Assertions. Currently testing generic collection-like classes that accept custom comparers is a bit tedious. |
Do you think that other methods would benefit from custom comparers that override the default behavior? For example, I found this issue while looking for a way to provide custom comparer for |
Maybe, but that would require separate issues. This is about the |
Can this feature be documented in the documentation somewhere? I didn't see it anywhere |
For example
or
The text was updated successfully, but these errors were encountered: