RedirectToRoute assert reports failure, however it is not.
Closed this issue · 4 comments
Installed MVC4 version of FluentAssertions.MVC (via nuget).
Solution has set .Net Framework 4.5.1 and MVC 5 Web.
Trying to use it in tests resulted in this weird error. I suspect there is some incompatibility issues somewhere...
Test Source: ***\BaseControllerTests.cs : line 31
Test Outcome: Failed
Test Duration: 0:00:00.1784214
Result Message: Expected ActionResult to be "RedirectToRouteResult", but found "RedirectToRouteResult"
Result StackTrace:
at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\LateBoundTestFramework.cs:line 17
at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\DefaultAssertionStrategy.cs:line 23
at FluentAssertions.Execution.AssertionScope.FailWith(String failureMessage, Object[] failureArgs) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\AssertionScope.cs:line 165
at FluentAssertions.Mvc.ActionResultAssertions.BeRedirectToRouteResult(String reason, Object[] reasonArgs)
Test code:
// prepare
var context = HttpMocks.GetControllerContextMock().Object;
var contr = new UnprotectedBase { ControllerContext = context };
// act
var result = contr.RedirectBack();
// assert
result.Should().BeRedirectToRouteResult();
I have seen a similar error before when using the MVC 3 build of FA.MVC with an MVC 4 project.
Can you try your test on an MVC 4 project with FA.MVC 4 to confirm if it is an MVC compatibility issue?
On 27 Dec 2013, at 11:57, Anrijs Vitolins notifications@github.com wrote:
Installed MVC4 version of FluentAssertions.MVC (via nuget).
Solution has set .Net Framework 4.5.1 and MVC 5 Web.
Trying to use it in tests resulted in this weird error. I suspect there is some incompatibility issues somewhere...Test Source: ***\BaseControllerTests.cs : line 31
Test Outcome: Failed
Test Duration: 0:00:00.1784214Result Message: Expected ActionResult to be "RedirectToRouteResult", but found "RedirectToRouteResult"
Result StackTrace:
at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\LateBoundTestFramework.cs:line 17
at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\DefaultAssertionStrategy.cs:line 23
at FluentAssertions.Execution.AssertionScope.FailWith(String failureMessage, Object[] failureArgs) in d:\Workspace\Github\FluentAssertions\FluentAssertions.Net35\Execution\AssertionScope.cs:line 165
at FluentAssertions.Mvc.ActionResultAssertions.BeRedirectToRouteResult(String reason, Object[] reasonArgs)
Test code:// prepare var context = HttpMocks.GetControllerContextMock().Object; var contr = new UnprotectedBase { ControllerContext = context }; // act var result = contr.RedirectBack(); // assert result.Should().BeRedirectToRouteResult();—
Reply to this email directly or view it on GitHub.
Ok, I just reproduced this.
Adding the following binding redirect to the test project's app.config fixed it and the test runs as expected:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
Does this fix work for you, or do you think we need an MVC 5 specific build? I am reluctant to make one, as I'm not aware of any new functionality in MVC 5 which we can't test using FA.MVC 4.
Thoughts?
Thanks. That worked. I believe if it does not require changes in package and can be documented then it is sufficient until MVC5 takes over older versions and becomes more widely used to have its own package.
Happy New Year!
Great, I'll update the readme when I get a moment.