title: Mocking a method that has optional parameter
body: <p>I have a method <code>public void SendMail(string email, string subject, string body, List&lt;Attachment&gt; attachements = null)</code> where last parameter can be <code>null</code> or <code>List&lt;Attachment&gt;</code>. </p>
  
  <p>I mocked it like this:</p>
  
  <pre><code>        var mailMock = new Mock&lt;IMailService&gt;();
          mailMock.Setup(m =&gt; m.SendMail(It.IsNotNull&lt;string&gt;(), It.IsNotNull&lt;string&gt;(), It.IsNotNull&lt;string&gt;(), It.IsAny&lt;List&lt;Attachment&gt;&gt;())).Verifiable();
          mailMock.Verify();
  </code></pre>
  
  <p>But it doesn't allow <code>null</code> values in attachment parameter. How can I allow both <code>null</code> and <code>List&lt;Attachment&gt;</code> to be passed?</p>
  
  <p>UPDATE: Actually, it is working, it's just that I invoked <code>mailMock.Verify();</code> too early, before actual call to tested method.</p>