title: Unit Testing Service Layer in .NET
body: <p>I am developing a new MVC 5 Application.  I have an Integration Layer in my project where I have a service reference to an external web service.</p>
  
  <p>I then created a interface that has some methods - I then have a service class which looks something like below:</p>
  
  <pre><code>public class MyService : IMyService
  {
      private readonly ExternalServiceClient _serviceClient;
  
      public MyService()
      {
          _serviceClient = new ExternalServiceClient ("WSHttpBinding_IMyService");
      }
  
      public string GetName(Coordinate[] coordinates)
      {
          string name = string.Empty;
  
          name = _serviceClient.GetInformationsForCoordinates(coordinates);
  
          return name;
      }
  </code></pre>
  
  <p>Note this is stripped down and in reality will add try catch block with Exception Handling, etc</p>
  
  <p>I have a Integration.Tests project for Unit Testing of the integration layer.  What is the best practice way of testing the GetName method.  Should I add another Service Reference to the endpoint of the service in the Tests project or if we are using Moq can I create a instance of my actual service that the Web Layer for example will call - and how would that be done?</p>