title: Unit Testing Interfaces with Moq
body: <p>I'm new to Moq and unit testing. I have been doing a unit test and this is the following code:</p>
  
  <pre><code>private Mock&lt;IServiceAdapter&gt; repository;
  
      [TestInitialize]
      public void Initialize()
      {
          repository= new Mock&lt;IServiceAdapter&gt;();
      }
  
  [TestMethod()]
      public void SaveTest()
      {
          //Setup 
          string Name = "Name1"; 
          string Type = "1";
          string parentID = null;
  
          repository.Setup(x =&gt; x.Save(Name , Type, parentID)).Returns("Success").Verifiable();
  
          //Do
          var result = repository.Object.Save(Name , Type, parentID);
          //Assert
          repository.Verify();
      }
  </code></pre>
  
  <p>My problem is that the test will always return the string that I put in the Returns parameter, in other words, it will always return "success" or whatever I write in its place. I guess thats not right because thats not the real behavior of the service. Anyone knows how I can mirror the real behavior of the "Save" service I'm trying to test? So lets say, if the return string is different from the service method,then the test should fail.</p>
  
  <p>Edited</p>
  
  <p>The ServiceAdapter interface its just a wrapper for a Web Service which I call like a REST Service. It's a Web Forms Project. </p>
  
  <p>I'm doing something like in this post </p>
  
  <p><a href="https://stackoverflow.com/questions/1615093/how-to-mock-a-web-service">How to mock a web service</a></p>
  
  <p>Should I create something like a FakeController with Dependency Injection to make it work?</p>