-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Closed
Copy link
Labels
api-approvedAPI was approved, it can be implementedAPI was approved, it can be implemented
Description
I was wondering if it would make sense to include an extension method for Exactly.Times like this:
myString.Should().Contain("something", 4.Times()); // Equivalent to Exactly.Times(4)I think it reads a bit better than the existing Exactly.Times(4), but perhaps this has already been considered?
I understand there might be some confusion around AtLeast, AtMost etc., but that might be fixed like:
myString.Should().Contain("something", 4.TimesOrMore()); // Equivalent to AtLeast.Times(4) and MoreThan(3)
myString.Should().Contain("something", 4.TimesOrLess()); // Equivalent to AtMost.Times(4) and LessThan(5)There seems to be some redundancy in with AtLeast/MoreThan and AtMost/LessThan, but they might be useful in scenarios I've never had.
I know creating such extensions is pretty straightforward:
public static class FluentOccurrenceConstraintExtensions
{
public static OccurrenceConstraint Times(this int times)
{
return Exactly.Times(times);
}
public static OccurrenceConstraint TimesOrLess(this int times)
{
return AtLeast.Times(times);
}
public static OccurrenceConstraint TimesOrMore(this int times)
{
return AtMost.Times(times);
}
}Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved, it can be implementedAPI was approved, it can be implemented