title: Mocking a service class using unit tests
body: <p>There is this codebase where we use automapper and have a layer, Cafes. Which has its object for data representation, CafeService.</p>
  <pre><code>class CafeService
  
  public async Task&lt;CafeResponse&gt; Get(int cafeId)
          {
              var cafe = await _cafeRepository.GetByIdAsync(cafeId);
  
           
              return _mapper.Map&lt;CafeResponse&gt;(cafe);
          }
  </code></pre>
  <p>How would you go about mocking a mapper in unit tests? Something I haven't done before. This is my unit test so far..</p>
  <pre><code> public async Task Get_ShouldReturnCafeID_WhenCafesInDatabase()
    {
  
              var cafeDto = new Cafe
              {
                  cafeId = 2
              };
  
             _cafeRepoMock.Setup(x =&gt; x.GetByIdAsync(cafeId))
                  .ReturnsAsync(cafeDto);
  
              //Act
              var cafeResponse = await _sut.Get(cafeId);
  
  
              ////Assert
              Assert.Equal(cafeId, cafeResponse.cafeId);
  
  }
  </code></pre>
  <p>When I run this test my _mapper currently outputs null assuming that's because I haven't mocked the mapping.</p>
  <p>Trying to get my head around how to really test the .Get() which checks if the paramters are passed correctly for the individual dependency calls based on the responses.</p>