title: How mock a method with one parameter with moq
body: <p>I'm not familiar with mocking. I'd like test if my method GetById return me an object User with an Id. Below the code, I'd like test if the GetById(10) return me an User with id = 10.</p>
  
  <p>I set the moq (I hope it's correct) but how execute the moq ?</p>
  
  <p>Thanks,</p>
  
  <pre><code>[TestMethod]
  public void MyMoq()
  {
      var userMock = new Mock&lt;IUsers&gt;();
      userMock.Setup(x =&gt; x.GetById(10)).Returns(new User());
  
      //After ?
      new Users().GetById(10);
  }
  
  public interface IUsers
  {
      IUser GetById();
  }
  
  public IUser GetById(int id)
  {
      using (var context = ....)
      {
          //code here
  
          //return user here
      }
  }
  </code></pre>