In Part 1 of this series, we started with a basic Data-Reader / SQL Connection/Command pattern and illustrated how it is possible to abstract the parsing of the Data Reader into a standalone object that can be fully unit tested in isolation of the calling code. In Part two of the series, we will highlight a very simple optimisation that can be made to the “DataReader” convertor and the required update to the tests to . . .
Recently we’ve been looking at improving our unit test code coverage and reducing the amount of duplicated code around our bespoke data access layer. Where possible we have moved over to NHibernate but certain parts of the data access must still be written using the standard ADO.NET connection/command pattern. Typically hidden right in the middle of this bespoke code is a while loop that is pivoting a data reader into a POCO that is impossible . . .
I’ve just installed MVC3.0 on a fresh PC using the new web installer application and was surprised at how long it seemed to be taking. Digging around a bit deeper I remembered that in the options I’d selected to use IIS rather than IIS Express and taking a quick look at the service panel highlighted that IIS was currently stopped. I restarted IIS and the MVC3.0 installation finished in seconds! So if you’re having problems . . .
Whilst working with VS2010 projects it can be really frustrating if you accidentally create your unit testing projects as class libraries (or migrate an existing class library into a unit testing library mainly because the context-sensitive “Add New” menu no longer contains the “New Test” option. This can be easily fixed by directly amending the project file, adding the following key to the main tag: <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> Reload the project in VS2010 and now your class . . .