I found a wee issue with the ASP.NET MVC Web Application template with the Authorize
attribute. Initially I was in two minds whether to convert the existing app or create a new project from template and port the code over - I took the second option as this usually causes the least amount of angst in the long run..
So the issue was found when trying to use the Authorize attribute to redirect to the template login page. By default the has web.config with the following authentication section
<authentication mode="Forms">
<forms loginUrl="~/Account/LogIn" />
</authentication>
but the AccountController action is called LogOn! Note the subtle difference between LogIn and LogOn...
Using the Beta 1 of ASP.NET MVC I was trying to use Moq to test a controller action that used the UpdateModel using a FormCollection as the value provider. Reading Scott Guthrie's post for Beta 1 he makes it clear that it should be possible not to mock the context for the controller to descrease unit test friction - however any use of the UpdateModel generates an ArgumentNullException...
So I still had to mock - hopefully this will be worked out in the next beta but for now using Moq this is the minimum required to Mock the ControllerContext.
var routeData = new RouteData();
var httpContext = new Mock<HttpContextBase>();
var controllerContext = new Mock<ControllerContext>(httpContext.Object, routeData,controller);
controller.ControllerContext = controllerContext.Object;
I like to have all dependencies for a project in the source code repository so that the solution can build for new developers straight from a check out. After having to work sift through the NUnit binary (again) to work out what I needed rather than reference the GAC, this list is as a reminder:
nunit-console-runner.dll
nunit-console.exe
nunit-console.exe.config
nunit-gui-runner.dll
nunit.core.dll
nunit.core.extensions.dll
nunit.core.interfaces.dll
nunit.exe
nunit.exe.config
nunit.framework.dll
nunit.framework.extensions.dll
nunit.mocks.dll
nunit.uikit.dll
nunit.util.dll
This includes the UI stuff required for running the GUI - just in case there is someone out there that doesn't have resharper...
Using service factory modelling edition recently I managed to get a new service project into a position where it would not generate code with no indication as to why. I knew it was my fault as I had deleted, moved and renamed projects a few times - it was one of those situations where I wanted to get the name right, but had an indecisive few minutes changed it, then eventually settled on the first name. The self inflicted mess I managed to end up with was two projects in the project mapping table, and obviously by sheer luck I had chosen the one that referenced the deleted projects!
I resolves it by opening the ProjectMapping.xml and finding the ProjectMappingTable element that contained the correct projects references - basically this meant finding by project Id those projects that still exist in the solution file.