Skip to content

Commit ab5380b

Browse files
committed
Beginnings of #47
1 parent 6944eba commit ab5380b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

TestStack.FluentMVCTesting.Tests/ControllerResultTestTests/ShouldRedirectToTests.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,24 @@ public void Check_for_redirect_to_incorrect_action_in_another_controller()
179179
Assert.That(exception.Message, Is.EqualTo("Expected redirect to action 'SomeOtherAction', but instead was given a redirect to action 'SomeAction'."));
180180
}
181181

182+
// TODO:
183+
// Remove this test instead of commenting it.
184+
// Give this issue 47 test a better name.
185+
186+
//[Test]
187+
//public void Check_for_redirect_to_action_with_non_specified_controller()
188+
//{
189+
// var exception = Assert.Throws<ActionResultAssertionException>(() =>
190+
// _controller.WithCallTo(c => c.RedirectToAnotherActionNoController()).ShouldRedirectTo<SomeOtherController>(c => c.SomeOtherAction())
191+
// );
192+
// Assert.That(exception.Message, Is.EqualTo("Expected redirect to action 'SomeOtherAction' in 'SomeOther' controller, but instead was given redirect to action 'SomeAction' within the same controller."));
193+
//}
194+
182195
[Test]
183-
public void Check_for_redirect_to_action_with_non_specified_controller()
196+
public void Issue47()
184197
{
185-
var exception = Assert.Throws<ActionResultAssertionException>(() =>
186-
_controller.WithCallTo(c => c.RedirectToAnotherActionNoController()).ShouldRedirectTo<SomeOtherController>(c => c.SomeOtherAction())
187-
);
188-
Assert.That(exception.Message, Is.EqualTo("Expected redirect to action 'SomeOtherAction' in 'SomeOther' controller, but instead was given redirect to action 'SomeAction' within the same controller."));
198+
_controller.WithCallTo(c => c.RedirectToActionWithNoParameters())
199+
.ShouldRedirectTo<ControllerResultTestController>(c => c.ActionWithNoParameters());
189200
}
190201
}
191202
}

TestStack.FluentMvcTesting/ControllerResultTest/ShouldRedirectTo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ public RouteValueDictionary ShouldRedirectTo<TController>(MethodInfo methodInfo)
117117
var redirectResult = (RedirectToRouteResult)ActionResult;
118118

119119
if (redirectResult.RouteValues["Controller"] == null)
120-
throw new ActionResultAssertionException(string.Format("Expected redirect to action '{0}' in '{1}' controller, but instead was given redirect to action '{2}' within the same controller.", actionName, controllerName, redirectResult.RouteValues["Action"]));
120+
//throw new ActionResultAssertionException(string.Format("Expected redirect to action '{0}' in '{1}' controller, but instead was given redirect to action '{2}' within the same controller.", actionName, controllerName, redirectResult.RouteValues["Action"]));
121+
{
122+
return redirectResult.RouteValues;
123+
}
121124

122125
if (redirectResult.RouteValues["Controller"].ToString() != controllerName)
123126
throw new ActionResultAssertionException(string.Format("Expected redirect to controller '{0}', but instead was given a redirect to controller '{1}'.", controllerName, redirectResult.RouteValues["Controller"]));

0 commit comments

Comments
 (0)