Skip to content

Improve ShouldRedirectTo<TController> exception message #47

@AlexArchive

Description

@AlexArchive

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions