views:

78

answers:

1

I've implemented an OpenID controller using Dnoa. I was using the approach found in the RP MVC template for dnoa, which returns IAuthenticationRequest.RedirectingResponse.AsActionResult() from the controller action. However, I've now found the controller very difficult to test using Moq because of this method.

I changed the controller to instead invoke IAuthenticationRequest.RedirectToProvider() and return null for the ActionResult, which seems to have the same effect. RedirectToProvider should be easier to mock, but is it appropriate to return null from the controller in this case?

A: 

The AsActionResult method is meant for MVC, obviously. I would encourage you to use it.

Can you tell me why it's difficult to test?

Andrew Arnott
Moq was having problems with RedirectingResponse.AsActionResult(), but not with RedirectToProvider(). What would be problematic about using RedirectToProvider in MVC, and just returning a new EmptyResult?
olivehour
I'm not sure anything would go wrong. But the spirit of MVC is to return the result rather than call RedirectToProvider, which calls ASP.NET's Response.End() method, which *usually* throws a ThreadInterruptedException.
Andrew Arnott