title: Moq: Invalid callback. Setup on method with parameters cannot invoke callback with parameters
body: <p>I am trying to use Moq to write a unit test. Here is my unit test code:</p>
  <pre><code>var sender = new Mock&lt;ICommandSender&gt;();
  sender.Setup(m =&gt; m.SendCommand(It.IsAny&lt;MyCommand&gt;(), false))
        .Callback(delegate(object o)
        {
            var msg = o as MyCommand;
            Assert.AreEqual(cmd.Id, msg.Id);
            Assert.AreEqual(cmd.Name, msg.Name);
        })
        .Verifiable();
  </code></pre>
  <p><code>SendCommand</code> takes an object and optional boolean parameter. And MyCommand derives from ICommand.</p>
  <pre><code>void SendCommand(ICommand commands, bool idFromContent = false);
  </code></pre>
  <p>When the test runs, I see the error</p>
  <pre><code>System.ArgumentException : Invalid callback. Setup on method with parameters (ICommand,Boolean) cannot invoke callback with parameters (Object).
  </code></pre>
  <p>I want to check if the content of the message is what I sent in. I searched the forum and found a couple of different variations of this issue, but those didn't help. Any help is greatly appreciated.</p>