title: How do I verify a method was called?
body: <p>I have a <code>ICreateService</code> class that has dependency on <code>ITicketApiAdapter</code>. I've tried registering a mock ITicketAdaper so that it gets injected when I create an anonymous create service.</p>
  
  <p>So, in setup, I have this register for the ticket adapter:</p>
  
  <pre><code>Fixture.Register(() =&gt;
      {
          var ticketApiAdapter = new Mock&lt;ITicketApiAdapter&gt;();
          ticketApiAdapter
              .Setup( x =&gt; x.AddTicketComment(
                  It.IsAny&lt;User&gt;(), 
                  It.IsAny&lt;Customer&gt;(), 
                  It.IsAny&lt;TicketComment&gt;()))
          .Returns(new SaveResult
                          {
                              Success = true, 
                              Id = Fixture.CreateAnonymous&lt;Guid&gt;().ToString()
                          });
  
          return ticketApiAdapter;
      });
  
  Fixture.Register(() =&gt; new CreateService(Fixture.CreateAnonymous&lt;Mock&lt;ITicketApiAdapter&gt;&gt;().Object));
  </code></pre>
  
  <p>From my understanding, that should "freeze" both the <code>ICreateService</code> and <code>Mock&lt;ITicketApiAdapter&gt;</code> so that when I request an anonymous instance, it's the one I registered.</p>
  
  <p>I have a test that looks like this:</p>
  
  <pre><code>[TestMethod]
  public void CreateServiceCallsAddTicketComment()
  {
      var apiTicketAdapter = Fixture.CreateAnonymous&lt;Mock&lt;ITicketApiAdapter&gt;&gt;();
      var createTicketRequest = Fixture.CreateAnonymous&lt;CreateTicketComment&gt;();
      var createService = Fixture.CreateAnonymous&lt;CreateService&gt;();
  
      var results = createService.CreateTicketComment(createTicketRequest);
  
      apiTicketAdapter
          .Verify(x =&gt; x.AddTicketComment(
              It.IsAny&lt;User&gt;(), 
              It.IsAny&lt;Customer&gt;(), 
              It.IsAny&lt;TicketComment&gt;()), 
          Times.Once());
  
      Assert.IsTrue(results.All(x =&gt; x.Success));
      Assert.IsTrue(results.All(x =&gt; x.Errors.Count == 0));
  
  }
  </code></pre>
  
  <p>I expect the apiTicketAdapter to be the one I registered so that I can verify the method is called. If I step through, the TicketApiAdapter is called, but Moq says it wasn't.</p>
  
  <h2>Edit</h2>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>CreateServiceCallsAddTicketComment threw exception: 
    Moq.MockException:  Expected invocation on the mock once, but was 0
    times: x => x.AddTicketComment(It.IsAny(), It.IsAny(),
    It.IsAny())</p>
    
    <p>Configured setups: x => x.AddTicketComment(It.IsAny(),
    It.IsAny(), It.IsAny()), Times.Never No
    invocations performed.</p>
  </blockquote>