title: Mock an update method returning a void with Moq
body: <p>In my test, I defined as data a <code>List&lt;IUser&gt;</code> with some record in.</p>
  
  <p>I'd like setup a moq the methode <code>Update</code>, this method receive the user <code>id</code> and the <code>string</code> to update.</p>
  
  <p>Then I get the the <code>IUser</code> and update the property <code>LastName</code></p>
  
  <p>I tried this :</p>
  
  <pre><code>namespace Tests.UnitTests
  {
      [TestClass]
      public class UsersTest
      {
          public IUsers MockUsersRepo;
          readonly Mock&lt;IUsers&gt; _mockUserRepo = new Mock&lt;IUsers&gt;();
          private List&lt;IUser&gt; _users = new List&lt;IUser&gt;();
  
          [TestInitialize()]
          public void MyTestInitialize()
          {
              _users = new List&lt;IUser&gt;
                  {
                      new User { Id = 1, Firsname = "A", Lastname = "AA", IsValid = true },
                      new User { Id = 1, Firsname = "B", Lastname = "BB", IsValid = true }
                  };
  
              Mock&lt;IAction&gt; mockUserRepository = new Mock&lt;IAction&gt;();
              _mockUserRepo.Setup(mr =&gt; mr.Update(It.IsAny&lt;int&gt;(), It.IsAny&lt;string&gt;()))
                  .Returns(???);
  
              MockUsersRepo = _mockUserRepo.Object;
          }
  
          [TestMethod]
          public void Update()
          {
              //Use the mock here
          }
  
      }
  }
  </code></pre>
  
  <p>But I get this error : <em>cannot resolve Returns symbole</em></p>
  
  <p>Do you have an id ?</p>
  
  <pre><code>class User : IUser
  {
      public int Id { get; set; }
      public string Firsname { get; set; }
      public string Lastname { get; set; }
      public bool IsValid { get; set; }
  }
  
  interface IUser
  {
      int Id { get; set; }
      string Firsname { get; set; }
      string Lastname { get; set; }
      bool IsValid { get; set; }
  }
  
  interface IAction
  {
      List&lt;IUser&gt; GetList(bool isActive);
      void Update(int id, string lastname)
  }
  
  class Action : IAction
  {
      public IUser GetById(int id)
      {
          //....
      }
      public void Update(int id, string lastname)
      {
          var userToUpdate = GetById(id);
          userToUpdate.LastName = lastname;
          //....
      }
  }
  </code></pre>