title: Setup Method With Params Array
body: <p>I am developing tests for an application. There's a method that has a <code>params</code> array as a parameter. I have set up the method using Moq but when I run the test, the return value of the method is null, which means it is not being mocked.</p>
  
  <p>Here's a code sample:</p>
  
  <pre><code>public interface ITicketManager {
      string GetFirstTicketInQueueIfMatches(params string[] ticketsToMatch);
  }
  
  public class TicketManager : ITicketManager {
      private Queue&lt;string&gt; ticketQueue = new Queue&lt;string&gt;();
  
      public string GetFirstTicketInQueueIfMatches(params string[] ticketsToMatch) {
          var firstQueuedTicket = ticketQueue.Peek();
          var firstQueuedTicketMatchesAnyOfRequested = ticketsToMatch.Any(t =&gt; t == firstQueuedTicket);
  
          if(firstQueuedTicketMatchesAnyOfRequested)
              return firstQueuedTicket;
  
          return null;
      }
  }
  </code></pre>
  
  <p>The mock code looks like this:</p>
  
  <pre><code>var mock = new Mock&lt;ITicketManager&gt;();
  
  mock.Setup(m =&gt; m.GetFirstTicketInQueueIfMatches(It.IsAny&lt;string&gt;()))
      .Returns(p =&gt; { 
      if(p.Contains("A"))
              return "A";
  
      return null;
  });
  </code></pre>
  
  <p>Why is it never hitting the mocked method?</p>