title: Is .Callback the right way to mock a void-returning method using Moq?
body: <p>I would like to unit test an Add method in a repository that returns void. I'm interested in testing the actual adding of elements without hitting the database (not whether Add was called or not). Is this the correct way?</p>
  
  <pre><code>var list = new List&lt;Foo&gt;();
  var repo = new Mock&lt;IFooRepository&gt;();
  
  repo.Setup(x =&gt; x.Add(It.IsAny&lt;Foo&gt;()))
              .Callback((Foo f) =&gt;
              {
                  list.Add(f);
              });
  
  repo.Object.Add(new Foo { FooId = 1 });
  
  Assert.IsTrue(list.Any(x =&gt; x.FooId == 1));
  </code></pre>