title: Moq Setup with function that accepts a list of objects, how to define object Ids that can be accepted?
body: <p>I have the below Moq service. One of the functions accepts various parameters but one of them is a <code>List&lt;MyObject&gt;</code> where <code>MtObject</code> has an <code>Id</code>. I have tried to define the actual object that the Moq should accept in order to return what I want returned for that object but it doesn't work - nothing is being returned - I'm wondering if it is because the object supplied isn't the exact object used when we call the Moq service - so I was going to try specifying the <code>MyObject.Id</code> in the setup but I can't figure out how to do it.</p>
  
  <p>This was my original:</p>
  
  <pre><code>myService.Setup(s =&gt; s.GetSomeStuff(
      It.IsAny&lt;Reference&gt;(),
      new List&lt;MyObject&gt;() { fakeMyObject1, fakeMyObject2 },
      anotherThing,
      number))
  .Returns(MyResponse).Verifiable();
  </code></pre>
  
  <p>The above returns <code>null</code>, if I use <code>It.IsAny&lt;List&lt;MyObject&gt;&gt;()</code> then I get a response but I need to have a different response based on the <code>MyOject</code> passed in.</p>
  
  <p>What would I replace this line with in order to specify the <code>fakeObject1.Id</code> and <code>fakeObject2.Id</code> rather than the object?</p>
  
  <pre><code>new List&lt;MyObject&gt;() { fakeMyObject1, fakeMyObject2 }
  </code></pre>
  
  <p>Or do you think the original solution should work? Or is there another alternative?</p>