I’m using MVC 4 (beta), and having some problems trying to test an auth attribute I’ve written.
In order to look into this some more, I’m trying to use the debug into .net framework sources debugging options, to see exactly what is going wrong. I’ve followed the setup instructions here: http://weblogs.asp.net/gunnarpeipman/archive/2010/07/04/stepping-into-asp-net-mvc-source-code-with-visual-studio-debugger.aspx
After doing all this, when I debug into my tests to see what is going on, when I come to step into the line of code that calls into the .net fw, the test just terminates and gives me the exception I’m trying to debug. For completeness, here’s my code:
var controller = new MyController();
controller.SetFakeAuthenticatedControllerContext("foo"); // Set up a fake http context for the user
var actionDescriptor = new Mock<ActionDescriptor>();
actionDescriptor.SetupGet(x => x.ActionName).Returns("AddedForTest");
var context = new AuthorizationContext(controller.ControllerContext, actionDescriptor.Object);
var auth = new SamCommandAuthenticationAttribute();
auth.OnAuthorization(context); // On this line the test will just terminate
Assert.Pass(); // This line would never be called.
Does anyone know why I’m not able to debug into the .net sources?
Microsoft Symbol server provides symbols for a subset of .net framework assembly.
I don’t think Mvc4 beta is one of them…
—-Added—
As Bond pointed out in the comment if you want to step into MVC4 Beta sources you have to include the mvc project in your solution and reference it from there, by first removing the reference to the GAC version which you’ve installed