title: Mock Abstract class using Moq
body: <p>I have the below abstract class and test method. Using "Moq" i got the below error:</p>
  
  <p>My Abstact class :</p>
  
  <pre><code>   public abstract class UserProvider
  { 
      public abstract UserResponseObject CreateUser(UserRequestObject request, string userUrl);
  
      public abstract bool IsUserExist(UserRequestObject request, string userUrl);
  }
  </code></pre>
  
  <p>Test Class :</p>
  
  <pre><code>  [TestMethod()]
      public void CreateUserTest()
      {
          var mockUserProvider = new Mock&lt;UserProvider&gt;(MockBehavior.Loose);
  
      //GetUserRequestObject is local method to set data
  
           mockUserProvider.
              Setup(u =&gt; u.CreateUser(GetUserRequestObject(), ""))
              .Returns(new UserResponseObject { uid = "123", uri = userUri }).Verifiable();
  
           var userProvider = mockUserProvider.Object.CreateUser(GetUserRequestObject(), "");
  
           mockUserProvider.Verify(u =&gt; u.CreateUser(GetUserRequestObject(), ""));
      }
  </code></pre>
  
  <p>Error Message :</p>
  
  <blockquote>
    <p>Moq.MockException:  Expected invocation on the mock at least once, but
    was never performed: u => u.CreateUser(.GetUserRequestObject(), "")</p>
  </blockquote>
  
  <p>Anyone please explain, why i got this message and how to resolve it?</p>