Unit testing data access

Roy Osherove blogs that he was mistaken when he suggesting using mocks for data access code.  With the improved Rollback attributes that he helped create, along with people like Justin Burtch who created a similar attribute for VSTS, they are now thinking that this is the way to go: rolling back database changes.

Roy is no fan of VSTS testing, finding a few bugs and some questionable design decisions.  Those don’t seem like deal breakers for me, but we will see.

BindingListView

The BindingList is very nice, but doens’t support some things like sort and filter that a lot of people would like to have (see here for a short discussion on BindingList vs Datatable).

This project, in sourceforge, called BindingListView is supposed to allow you to get a sorted or filtered “view” of a bindinglist.

Might be worth checking out.

Simulating HttpContext

Update: Phil Haack has updated his HttpContext Simulator with some new goodies.

Here is an article by Haacked showing how one can create a test friendly httpcontext.

I modified his example some and started using it in some tests; works very nice!

Here is another implementation based on Haack’s example that is supposed to also work with session.

I almost NEVER use session if I can avoid it, but still this could come in handy.

Null Object Refactoring

Here is a nice article on Null Object Refactoring, a process where you create a null representation of an object for use when you want to treat the object as null, rather than passing around a truely null object.

This is one of Fowlers refactoring suggestions from his book: Refactoring: Improving the Design of Existing Code and on his site: http://www.refactoring.com/catalog/introduceNullObject.html