title: Is it a good practice to mock Automapper in unit tests?
body: <p>There is this codebase where we use automapper and have 2 layers, <code>Domain</code> and <code>Service</code>. Each has its object for data representation, <code>DomainItem</code> and <code>ServiceItem</code>. The service gets data from domain, the uses constructor injected automapper instance to map </p>
  
  <pre><code>class Service 
  {
    public ServiceItem Get(int id)
    {
      var domainItem = this.domain.Get(id);
      return this.mapper.Map&lt;DomainItem, ServiceItem&gt;(domainItem);
    }
  }
  </code></pre>
  
  <p>Assume best practices, so mapper has no side-effects and no external dependencies. You'd write a static function to convert one object to another within seconds, just mapping fields.</p>
  
  <p>With this in mind, is it a good practice to mock the mapper in unit tests like this?</p>
  
  <pre><code>[TestClass]
  class UnitTests
  {
    [TestMethod]
    public void Test()
    {
      var expected = new ServiceItem();
  
      var mockDomain = new Mock&lt;IDomain&gt;();
      // ... setup
      var mockMapper = new Mock&lt;IMapper&gt;();
      mockMapper.Setup(x =&gt; x.Map&lt;DomainItem, ServiceItem&gt;(It.IsAny&lt;DomainItem&gt;()))
        .Returns(expected);
  
  
      var service = new Service(mockDomain.Object, mockMapper.Object);
      var result = service.Get(0);
  
      Assert.AreEqual(expected, result);
    }
  }
  </code></pre>
  
  <p>To me, it seems that such unit test does not really bring any value, because it is effectively testing only the mocks, So i'd either not write it at all OR I'd use the actual mapper, not the mocked one. Am I right or do I overlook something?</p>