title: When to use a Mocking Framework?
body: <p>So I am playing around with mocking frameworks (Moq) for my unit tests, and was wondering when you should use a mocking framework?</p>
  
  <p>What is the benefit/disadvantage between the following two tests:</p>
  
  <pre><code>public class Tests
  {
      [Fact]
      public void TestWithMock()
      {
          // Arrange
          var repo = new Mock&lt;IRepository&gt;();
  
          var p = new Mock&lt;Person&gt;();
          p.Setup(x =&gt; x.Id).Returns(1);
          p.Setup(x =&gt; x.Name).Returns("Joe Blow");
          p.Setup(x =&gt; x.AkaNames).Returns(new List&lt;string&gt; { "Joey", "Mugs" });
          p.Setup(x =&gt; x.AkaNames.Remove(It.IsAny&lt;string&gt;()));
  
          // Act
          var service = new Service(repo.Object);
          service.RemoveAkaName(p.Object, "Mugs");
  
          // Assert
          p.Verify(x =&gt; x.AkaNames.Remove("Mugs"), Times.Once());
      }
  
      [Fact]
      public void TestWithoutMock()
      {
          // Arrange
          var repo = new Mock&lt;IRepository&gt;();
  
          var p = new Person { Id = 1, Name = "Joe Blow", AkaNames = new List&lt;string&gt; { "Joey", "Mugs" } };
  
          // Act
          var service = new Service(repo.Object);
          service.RemoveAkaName(p, "Mugs");
  
          // Assert
          Assert.True(p.AkaNames.Count == 1);
          Assert.True(p.AkaNames[0] == "Joey");
      }
  }
  </code></pre>