Skip to content
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

Detect wrong-typed constraints #1246

Merged

Conversation

thomaslevesque
Copy link
Member

Fixes #1237

The 3rd commit is a simplification. I realized that only MatchesConstraint could be created by the argument constraint trap, so we don't need to introduce a Type property for other types of constraint.

Copy link
Member

@blairconrad blairconrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, @thomaslevesque. I did make a couple of minor comments. If you agree and implement the suggested changes, feel free to squash/amend as you go.

@@ -20,4 +22,9 @@ internal interface IArgumentConstraint
/// <returns>True if the argument is valid.</returns>
bool IsValid(object argument);
}

internal interface ITypedArgumentConstraint : IArgumentConstraint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in a separate file, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

"Then the call configuration throws a FakeConfigurationException"
.x(() => exception.Should().BeAnExceptionOfType<FakeConfigurationException>());

"And the message should indicate the actual and expected type"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: previous steps used the imperative mood, not the subjunctive (fun fact: I would probably not even know these moods exist were it not for learning about "le subjontif" in school).
Consider rewording. Maybe something like "And the message indicates the actual and expected types"
(oh, I changed "type" to "types" there as well)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

}

[Scenario]
public static void PassingHiddenConstraintWithWrongTypeToAMethod(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this test.

@thomaslevesque thomaslevesque force-pushed the detect-wrong-type-constraint branch 2 times, most recently from d472eea to be30855 Compare October 30, 2017 20:12
@thomaslevesque
Copy link
Member Author

The rebase was a bit messy, hopefully I didn't break anything...

@blairconrad
Copy link
Member

Nice, @thomaslevesque! Thanks.

@blairconrad blairconrad merged commit ba200ed into FakeItEasy:develop Oct 31, 2017
@thomaslevesque thomaslevesque deleted the detect-wrong-type-constraint branch October 31, 2017 12:17
@thomaslevesque
Copy link
Member Author

Thanks for the merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants