I have a WCF service that exposes 1 method GetNextObjectInList(int id)
which hits a DB.
The WCF service works, more or less, like this:
public class MyService : IDisposable
{
public MyService()
{
this.IntializeDBConnection();
}
public int GetNextObjectInList(int id)
{
/* uses DB connection */
}
/* Dispose releases DB connection */
}
This makes the client code relatively simple:
public void UseNextElementInList()
{
IMyService svc = new MyServiceClient();
int nextID = svc.GetNextObjectInList(this.ID);
/* use object */
}
I've written unit tests to test the WCF services objects, but I'd like to test the consumer code for various things like timing/performance/error handling but I don't know how to construct my tests such that the Service doesn't hit the DB.
Most of my tests (the tests that run against the service's objects for instance) DO create an in-memory DB but I don't know how to get the service to connect to that without test-specific code in the service.