views:

1069

answers:

4

Hi guys

I know that there has been a couple questions about tutorials on moq. But I am wondering if there are any sample apps out there that use moq in the context of an n-tier business application using ado.net.

I find the tutes good, but they don't seem to bring everything all together into the big picture. Thus, I am looking for a sample app that brings the full picture together.

Also, I think there is a little bit of a lack of examples which specifically deal with mocking and testing the logic in the data access layer.

Cheers Anthony

A: 

Any ideas???

vdhant
A: 

Moq, like all unit testing frameworks, should not have much a concept of n-tier-ness about it.

One would typically use unit testing to test each individual class one-at-a-time. When a particular class is a little more complex and relies on having references to component classes and calling methods on these component classes, one might use a mocking framework such as Moq to create these constituent components, and to have the class-under-test use these mocked components instead of the real deals.

It looks like you are looking for how to use Moq in integration testing, where you bring all the components together and test the whole shebang all at once, including the data-access components. For doing whole-shebang tests, typically you need the real components, not mocked versions of them.

Justice
A: 

Thanks for the reply, but I think you might have misunderstood me.

Unit testing is exactly what I want to do and I agree one would want to test each tier in isolation - which means it shouldn't matter if you are using n-tier or not. But I believe the semantics around testing the various layers are different.

For instance, testing ones data layer in isolation is very different to testing ones business layer in isolation. For instance, when testing the data layer one needs to try and abstract away the database, which is very different to abstracting out the data layer when testing the business layer.

Hence why I was after an end to end example.

vdhant
I ask myself the same question - I have never seen tests (theories) written that exercise the database but I am told that its good practice to write them and just keep them separate from your domain tests. Moq is great for domain tests. There's also Storyteller that does the full gamut...
cfeduke
+2  A: 

Edit 5/5/09: Moq was removed from this code base so you would have to download an older revision (140) to see the moq stuff.

Try SutekiShop - uses .NET 3.5, MVC, LINQ, Windsor, and Moq.

JC
are u sure it uses Moq? Homepage for that link says: Built using TDD with the following tools: * NUnit * Rhino Mocks
Pure.Krome