title: Expected invocation on the mock once, but was 0 times
body: <p>I need to define that in the method AddOrEdit triggered a different method Add. The add method adds a new instance. But I catch the the error. The Add method works in debug. What am I doing wrong?</p>
  
  <pre><code>var repository = new Mock&lt;IRepository&gt;();
  var layer = new Layer(repository.Object);
  
  // Arrange
  var object1=new Object1();
  var object2=new Object2();
  repository.Setup(a =&gt; a.Add&lt;Object1&gt;(new Object1(){Name="Name"}));
  
  // Act
  layer.AddOrEdit(object1, object2);
  
  // Assert
  repository.Verify(a =&gt; a.Add&lt;Object1&gt;(new Object1(){Name="Name"}));
  
  public void AddOrEdit(Object1 object1, Object2 object2))
  {
      ......
      ......
      Add(object2.Name)
  }
  public void Add(string name)
  {
       Repository.Add(new Object1(){Name="Name"});
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I removed</p>
  
  <pre><code>repository.Setup(a =&gt; a.Add&lt;Object1&gt;(new Object1(){Name="Name"}));
  </code></pre>
  
  <p>And override Equals</p>
  
  <pre><code>public override bool Equals(object obj)
  {
      var item = obj as Object1;
  
      return item != null &amp;&amp; this.Name.Equals(item.Name);
  }
  
  repository.Verify(a =&gt; a.Add&lt;Object1&gt;(new Object1(){Name="Name1"})); // Test Failed
  repository.Verify(a =&gt; a.Add&lt;Object1&gt;(new Object1(){Name="Name"}));  // Test Success
  </code></pre>
  
  <p><strong>Update2</strong>
  <a href="https://stackoverflow.com/a/17765935/2602098">Andy</a> offered a better solution</p>
  
  <p><code>repository.Verify(a =&gt; a.Add(It.Is&lt;Object1&gt;(y =&gt; y.Name == "Name")));</code></p>