title: Verifying a specific parameter with Moq
body: <pre><code>public void SubmitMessagesToQueue_OneMessage_SubmitSuccessfully()
  {
      var messageServiceClientMock = new Mock&lt;IMessageServiceClient&gt;();
      var queueableMessage = CreateSingleQueueableMessage();
      var message = queueableMessage[0];
      var xml = QueueableMessageAsXml(queueableMessage);
      messageServiceClientMock.Setup(proxy =&gt; proxy.SubmitMessage(xml)).Verifiable();
      //messageServiceClientMock.Setup(proxy =&gt; proxy.SubmitMessage(It.IsAny&lt;XmlElement&gt;())).Verifiable();
  
      var serviceProxyFactoryStub = new Mock&lt;IMessageServiceClientFactory&gt;();
      serviceProxyFactoryStub.Setup(proxyFactory =&gt; proxyFactory.CreateProxy()).Returns(essageServiceClientMock.Object);
      var loggerStub = new Mock&lt;ILogger&gt;();
  
      var client = new MessageClient(serviceProxyFactoryStub.Object, loggerStub.Object);
      client.SubmitMessagesToQueue(new List&lt;IMessageRequestDTO&gt; {message});
  
      //messageServiceClientMock.Verify(proxy =&gt; proxy.SubmitMessage(xml), Times.Once());
      messageServiceClientMock.Verify();
  }
  </code></pre>
  
  <p>I'm starting using Moq and struggling a bit.
  I'm trying to verify that messageServiceClient is receiving the right parameter, which is an XmlElement, but I can't find any way to make it work. It works only when I don't check a particular value.</p>
  
  <p>Any ideas?</p>
  
  <p>Partial answer:
  I've found a way to test that the xml sent to the proxy is correct, but I still don't think it's the right way to do it.</p>
  
  <pre><code>public void SubmitMessagesToQueue_OneMessage_SubmitSuccessfully()
  {
      var messageServiceClientMock = new Mock&lt;IMessageServiceClient&gt;();
      messageServiceClientMock.Setup(proxy =&gt; proxy.SubmitMessage(It.IsAny&lt;XmlElement&gt;())).Verifiable();
      var serviceProxyFactoryStub = new Mock&lt;IMessageServiceClientFactory&gt;();
      serviceProxyFactoryStub.Setup(proxyFactory =&gt; proxyFactory.CreateProxy()).Returns(messageServiceClientMock.Object);
      var loggerStub = new Mock&lt;ILogger&gt;();
  
      var client = new MessageClient(serviceProxyFactoryStub.Object, loggerStub.Object);
      var message = CreateMessage();
      client.SubmitMessagesToQueue(new List&lt;IMessageRequestDTO&gt; {message});
  
      messageServiceClientMock.Verify(proxy =&gt; proxy.SubmitMessage(It.Is&lt;XmlElement&gt;(xmlElement =&gt; XMLDeserializer&lt;QueueableMessage&gt;.Deserialize(xmlElement).Messages.Contains(message))), Times.Once());
  }
  </code></pre>
  
  <p>By the way, how could I extract the expression from the Verify call?</p>