Nettiers Mock scenario

212 views Asked by At

Does anybody have a good example of where you're using Nettiers and are able to do some form of mocking for the purposes of Unit testing. Battling to get my head around the idea.

My idea is to create a new provider and use this provider for all my unit testing. This provider will not connect to a DB but will rather have static data.

2

There are 2 answers

0
Fischermaen On

For that scenario I think that the mocking framework MOQ is a good decision. We use it in our company and are satisfied with it. For further information take a look at the homepage of moq open source project. With a mock like that you will have great opportunities to create your tests as you need it.

0
Rob Bird On

We have successfully mocked the netTiers services with typemock isolator.

Typemock worked well for us, because as it says in their features list, it allows you to mock "untestable code like: statics, sealed and non virtual methods" - while this is not a purest approach to mocking, it does allow you to test classes deeper into the code which you may be unable to inject easily. (in our case through our own bad design :-)

So in our example, we compile the netTiers solution to binaries and reference them in our projects. We then build our business services to wrap the netTiers services adding additional logic and in some cases caching. We hadn't build in any sort of dependency injection and added unit testing later in the day.

So using typemock we were able to create a test against our controller layer and have it test the controller and business service and just tell typemock that when a customerservice is instantiated in the business service layer, swap it out with a mock that returned fixed data instead.