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

Add ToString() for fluent setup API objects #812

Merged
merged 7 commits into from
Apr 18, 2019
Merged

Add ToString() for fluent setup API objects #812

merged 7 commits into from
Apr 18, 2019

Conversation

jacob-ewald
Copy link
Contributor

@jacob-ewald jacob-ewald commented Apr 17, 2019

When a Setup fails verification, it's helpful to have the exact expression that failed, rather than the default ToString() representation of the Setup class. To illustrate:

What I'd like to see in the output message:

x => x.DoThings(null)

What I actually get:

Moq.Language.Flow.VoidSetupPhrase`1[Moq.Tests.Regressions.IssueReportsFixture+IFoo]

This PR fixes that by overriding the ToString() methods and calling ToStringFixed() on the expression that is being used. This allows for a nicely formatted string representation of the expression to be returned.

Closes #810.

Copy link
Contributor

@stakx stakx left a comment

Choose a reason for hiding this comment

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

Generally LGTM! 👍 Just a few things for your consideration, my priority would be resolving the review comment about the changelog entry.

tests/Moq.Tests/Regressions/IssueReportsFixture.cs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/Moq/Language/Flow/SetupPhrase.cs Show resolved Hide resolved
@stakx stakx added this to the 4.11.0 milestone Apr 17, 2019
@stakx stakx changed the title Issue 810: Fix ToString() for Expressions Add ToString() for fluent setup API objects Apr 17, 2019
@jacob-ewald
Copy link
Contributor Author

I sent you some messages on gitter, but wanted to mention them here in case you don't get notifications from gitter.

@stakx stakx merged commit 3d7ac8c into devlooped:master Apr 18, 2019
@devlooped devlooped locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ToString() on SetupPhrase does not return expression
2 participants