Detect and reject an "argument constraint factory method" that produces two constraints
See original GitHub issueIt’s a weird situation to be in, but if it comes up, we should complain about it.
Specifically, this spec fails, because no exception is thrown (we just use the first constraint, not even the one that’s returned from the method):
[Scenario]
public static void ConstraintFactoryThatMakesTwoConstraints(
IHaveAnObjectParameter fake,
Func<object> constraintFactory,
Exception exception)
{
"Given a fake"
.x(() => fake = A.Fake<IHaveAnObjectParameter>());
"And a delegate that produces two constraints"
.x(() => constraintFactory = () =>
{
A<object>.That.Matches(i => i is object);
return A<object>.That.Matches(i => i is null);
});
"When I try to configure a method of the fake with this delegate"
.x(() => exception = Record.Exception(() => A.CallTo(() => fake.Bar(constraintFactory())).Returns(1)));
"Then the call configuration throws a FakeConfigurationException"
.x(() => exception.Should().BeAnExceptionOfType<FakeConfigurationException>());
}
(Of course, if we weren’t using a method to create constraints, and just specifying one inline via an expression, it’s only possible to create a single constraint.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Multiple constraint annotations confused on Java Bean ...
I defined two custom constraints ACheck and BCheck. @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @ ...
Read more >Overloading and generic constraints - Jon Skeet's coding blog
Okay, so we've got two methods called M with different constraints. I've given them both parameters of different reference types.
Read more >C++ Reference: class Solver - OR-Tools
This method creates a relation between two interval vars. MakeIntervalVarRelationWithDelay. Return type: Constraint*. Arguments: IntervalVar* const t1, ...
Read more >Integer Programming
There are two types of constraints for the model: i) the demand dj of each customer must be filled from the warehouses; and...
Read more >iris — Iris 3.7.0.dev35 documentation
Constraints are the mechanism by which cubes can be pattern matched and filtered according to specific criteria. Once a constraint has been defined,...
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
Good point!
Maybe. I don’t think we’re very consistent in the types of exceptions we throw…
This change has been released as part of FakeItEasy 5.3.0.