Replies: 2 comments 2 replies
-
|
We're (historically) using |
Beta Was this translation helpful? Give feedback.
0 replies
-
This bothers me too. I'd really love a version of list.Should().Contain(x => x is MyType m && m.MyProp == expected);I could write list.Should().Contain(x => x.Should().BeOfType<MyType>().Which.MyProp.Should().Be(expected)); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Uh oh!
There was an error while loading. Please reload this page.
-
I specifically want to do something like
list.Should().Contain(x => x is MyType m && m.MyProp == expected). But I think my question can be generalized to pattern matching in general, or even to "Why are predicatesExpression<Func<T, bool>>s?" But this can mostly be done with the help of theCallerArgumentExpressionattribute. It will be a little bit different, and you won't get the body if you build theFuncbefore (as you can with theExpressions).Could give the
Containmethod a signature like this,I don't think it'll clash with the original signature, and it'll give us full access to all C# feature in the predicate function.
I don't know, just an idea. I solved my original problem by doing
list.Should().Contain(x => x is MyType && ((MyType)x).MyProp == expected).Beta Was this translation helpful? Give feedback.
All reactions