Feature request: Should be with predicate?
See original GitHub issueBefore you file a bug, have you:
Description
I often come across functions that don’t exist, for instance "A".Should().BeUpperCase()
, and I was wondering if it would make sense to have an overload that takes a Predicate<T>
that determines the expectancy.
Complete minimal example reproducing the issue
// Arrange
string input = "MyString";
// Act
string actual = input.ToUpperInvariant();
Desired behavior:
// Arrange
string input = "MyString";
// Act
string actual = input.ToUpperInvariant();
// Assert
actual.Should().Be(actual => actual.All(ch => char.IsUpper(ch)));
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Feature Request: Predicate pushdown - FoundationDB Core
It would parse the predicate in whatever way it wants to for the layer's goal (regex, comparing numbers, etc.) and return true or...
Read more >Predicate mutations while moving predicates between ...
Are there any plans to remove this limitation by allowing mutations while predicates are being moved to a different group? Feature request: ...
Read more >Can I get type inference on multiple variables through a ...
There's a longstanding open feature request at microsoft/TypeScript#26916 asking for the ability to return multiple type predicates in a ...
Read more >[Pitch] Swift Predicates - Core Libraries
A predicate is a construct that performs a true/false test on a provided set of input values. It is very common for developers...
Read more >Predicate Boolean Support for prismicio.core - Features
Feature Idea (one per thread): Add additional type to predicate to enable query by boolean value in .NET Core package.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First of all Jonas, thanks for your nice comprehensive example. This comment is the missing bit I was unaware of. I didn’t know you can use anonymous types for verification, and I also thought it’ll fail if the properties do not match. That is a perfect solution. Thank you for your time and patience explaining all that.
Match
is the assertion you’re looking for.