How should I mock out my data connectivity

Posted by BobTheBuilder on Stack Overflow See other posts from Stack Overflow or by BobTheBuilder
Published on 2011-01-09T01:23:26Z Indexed on 2011/01/10 15:53 UTC
Read the original article Hit count: 125

Filed under:
|
|

I'm trying to unit test my Data Access Layer and I'm in the process of trying to mock my data connectivity to unit test my DAL and I'm coming unstuck trying to mock out the creation of the commands. I thought about using a queue of IDbParameters for the creation of the parameters, but the unit tests then require that the parameters are configured in the right order. I'm using MOQ and having looked around for some documentation to walk me through this, I'm finding lots of recommendation not to do this, but to write a wrapper for the connection, but it's my contention that my DAL is supposed to be the wrapper for my database and I don't feel I should be writing wrappers... if I do, how do I unit test the connectivity to the database for my wrapper? By writing another wrapper? It seems like it's turtles all the way down.

So does anyone have any recommendations or tutorials regarding this particular area of unit testing/mocking?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about unit-testing