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

Improve ShouldRedirectTo<TController> exception message #47

Closed
AlexArchive opened this issue Nov 25, 2014 · 5 comments
Closed

Improve ShouldRedirectTo<TController> exception message #47

AlexArchive opened this issue Nov 25, 2014 · 5 comments

Comments

@AlexArchive
Copy link
Contributor

When the consumer calls ShouldRedirectTo<TController> where TController is of the same type as the controller under test like this:

var sut = new HomeController();
sut.WithCallTo(c => c.Index())
    .ShouldRedirectTo<HomeController>(c => c.Index());

The assertion fails with the following error:

Expected redirect to action 'Index' in 'Home' controller, but instead was given redirect to action 'Index' within the same controller.

I encountered this error message when I mistakenly supplied the generic type argument. I knew to remove it because I have some experience with this library.

Maybe I am dumb or maybe this is a common mistake. Might it be helpful to change the exception message to something like this:

Expected redirect to action 'Index' in 'Home' controller, but instead was given redirect to action 'Index' within the same controller. If this was the intended assertion then please remove the generic type argument.

@robdmoore
Copy link
Member

Or we can make that scenario work. I don't see why that shouldn't pass...

On 26 Nov 2014, at 4:40 am, ByteBlast notifications@github.com wrote:

When the consumer calls ShouldRedirectTo where TController is of the same type as the controller under test like this:

var sut = new HomeController();
sut.WithCallTo(c => c.Index())
.ShouldRedirectTo(c => c.Index());
The assertion fails with the following error:

Expected redirect to action 'Index' in 'Home' controller, but instead was given redirect to action 'Index' within the same controller.

I encountered this error message when I mistakenly supplied the generic type argument. I knew to remove it because I have some experience with this library.

Maybe I am dumb or maybe this is a common mistake. Might it be helpful to change the exception message to something like this:

Expected redirect to action 'Index' in 'Home' controller, but instead was given redirect to action 'Index' within the same controller. If this was the intended assertion then please remove the generic type argument.


Reply to this email directly or view it on GitHub.

@AlexArchive
Copy link
Contributor Author

I wasn't too sure why it didn't pass either.

I assumed that you did it on purpose?

@robdmoore
Copy link
Member

No. It's an oversight ;)

On 26 Nov 2014, at 6:19 am, ByteBlast notifications@github.com wrote:

I wasn't too sure why it didn't pass either. I assumed that you did it on purpose?


Reply to this email directly or view it on GitHub.

@AlexArchive
Copy link
Contributor Author

Yeah of course. I will remove the if that throws and see if all the tests pass (soon).

@AlexArchive
Copy link
Contributor Author

Thank you for your input in all cases.

AlexArchive pushed a commit that referenced this issue Jan 18, 2015
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

No branches or pull requests

2 participants