-
Notifications
You must be signed in to change notification settings - Fork 21
Make fields and ValidateActionResultType on ControllerResultTest public #40
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
Comments
FYI for anyone curious, this is possible with a bit of (nasty) reflection as a hack in the interim of getting this functionality built-in: public static class ControllerResultTestExtensions
{
public static void MyCustomTestMethod<TController>(this ControllerResultTest<TController> result, ...)
where TController : Controller
{
var controller = result.GetType().GetField("_controller", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(result) as TController;
var actionResult = result.GetType().GetField("_actionResult", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(result) as ActionResult;
var actionName = result.GetType().GetField("_actionName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(result) as string;
...
} |
(I would have just done it, but the CI server isn't accessible behind the proxy here and Git isn't installed on this computer :(). |
Merged
I can do this for you no problem. I wonder what it is you wanted to achieve? Could we perhaps embed the assertion you need in the library? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would be useful to enable ability to create extension methods on ControllerResultTest so that you can check for your own custom ActionResult types.
The text was updated successfully, but these errors were encountered: