# Thursday, 01 December 2011

The Test Helpers are a great way to ease your testing needs with MVC.  If your using the Test Helpers to test your routing like so:

            "~/".ShouldMapTo<HomeController>(x => x.Index());

When you run your tests you’ll get the following error:

System.Security.VerificationException : Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument 'Your Controller Name’ violates the constraint of type parameter 'TController'.

The fix is a binding direct.

Add an app.config to your test project and paste in the following:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="" newVersion="" />

Happy Coding! Smile

Posted 12.01.2011  #    Comments [7]  | 
# Wednesday, 09 November 2011

I don’t know about you but every SQL Server environment I’ve ran into is extremely well documented and easy to figure out the dependencies.wakeup



…And then I wake up.



Documented SQL Servers?

Ever have a question about where in your SQL Server stored procedures you used that particular piece of text?

Maybe you need to know where you used that CLR integrated function call in your SQL Server code base?

I recently began a new job and while getting myself up to speed on their, I mean our database environment I discovered that the server had CLR integrated functions.  Where are these being used? Nobody on the team could give me a straight answer.

sp_MSForeachdb to the rescue

This built-in little gem (undocumented) will loop through all your databases on a server.  It takes in a string as a command with the ? as a placeholder for the table name.

sp_MSForeachdb ' use ?; SELECT DISTINCT ''?'' as DbName, o.name AS OBJ_Name, o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id=o.object_id WHERE (m.definition LIKE ''%YourTextToFind%'' )'

This will return an empty result set if the database does not have YourTextToFind in any of it’s stored procedures, views and functions.

When it does find it will look something like:

DbName OBJ_Name type_desc

Now you are armed with a list of usages/dependencies.  It’s a simple man’s database documentation tool. 

I imagine the above code could be better written.  After all, I’m just an accidental DBA. Smile

Here’s some cool usages floating around on the interwebs.

Find the space used for each database.

Six common uses of sp_MSforeachdb.

There’s also sp_MSforeachtable….  I think you can guess just what you might do with that.

Happy Coding!

Posted 11.09.2011  #    Comments [0]  | 
# Saturday, 29 October 2011

In a post about two months back I worked with Adam Anderly to update the SimpleMembershipMvc3.Sample application to include resetting/forgotten passwords and emailing verification of registration. 

Adam updated his NuGet package to include this.  He also separated the email code into a service to make it better for testing.  Go Adam!

How to get it

If you are familiar with NuGet the command is:

Install-Package SimpleMembership.Mvc3.Sample

If you aren’t familiar with NuGet yet, you need to be.  It’s a great tool!

You can also get the code via GitHub.

Happy Coding!

Posted 10.29.2011  #    Comments [0]  |