Unit Test Your .NET Data Access Layer: Where are the Mocks?

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/9/30/unit-test-your-net-data-access-layer-where-are-the-mocks.html
Published Tuesday, September 30, 2003 9:47 AM by RoyOsherove

Comments

Tuesday, September 30, 2003 11:22 AM by senkwe chanda

# re: Unit Test Your .NET Data Access Layer: Where are the Mocks?

I have yet to find an in depth tutorial on how best to use mocks. For example, lets say you're accesing your DB via the DAAB. What should you mock? Everything I've seen so far has been very simplistic, which might mean that it's so easy that people don't bother to write about it while I sit here going "huh??"
Tuesday, September 30, 2003 11:24 AM by Roy Osherove

# re: Unit Test Your .NET Data Access Layer: Where are the Mocks?

I totally agree! I've been into this same problem just today. I bet I can figure out a common pattern that lets us use the SQLHelper class with mock objects, it just might take some time. :)
Friday, April 23, 2004 1:53 PM by Craig Wagner

# re: Unit Test Your .NET Data Access Layer: Where are the Mocks?

I recently started with a new organization that is using NUnit. They have a data access component that was home-grown, and a mock object for unit testing. However, it seems very clumsy for several reasons:

- The data access component should really consist of static members only. There is no client-specific state that needs to be maintained. However, the mock object changes that so I must create AND PASS AROUND the object. Now my application design is manged because of the requirements of testing.

- The mock object responds to the SEQUENCE OF CALLS. If I refactor my object such that the sequence of calls changes, my tests break. That strikes me as stupid, at least in the case of retrievals. I spent two days debugging the tests because they were now inserting data into the mock component in the wrong sequence.
Thursday, December 09, 2004 1:04 PM by TrackBack

# I changed my mind - Mock objects are wrong for database unit testing

Thursday, December 09, 2004 8:41 PM by TrackBack

# I changed my mind - Mock objects are wrong for database unit testing