Do I have to rewrite my code to do this into an interface? Or is there an easier way? I am using Moq
What I usually do is build a wrapper or an adapter around my web service and just mock that.
for instance:
public class ServiceAdapter: IServiceAdapter
{
public void CallSomeWebMethod()
{
var someService = new MyWebService();
someService.SomeWebMethod();
}
}
Then I just stub the service adapter.
[Test]
public void SomeMethod_Scenario_ExpectedResult()
{
var adapterMock = new Mock();
//do your test
}