title: Moq setup returns null object when the method is called by a UnitTest
body: <p><strong>Test Setup</strong> </p>
  
  <blockquote>
    <p>Mock gives null object when the test hits the method inside the controller </p>
  </blockquote>
  
  <p>My controller's constructor has two dependencies which I mocked.  While running the test for CheckOut it is giving null object in the result. I am using AutoMapper to map between Model objects and Business</p>
  
  <pre><code>[Fact]
  public void CheckOutSomethingsTest()
  {
      Mock&lt;ICheckoutService&gt; checkoutServiceMock = new Mock&lt;ICheckoutService&gt;();
      Mock&lt;IMapper&gt; mapperMock = new Mock&lt;IMapper&gt;();
  
      checkoutServiceMock.Setup(c =&gt; c.CheckoutSomethings(new CheckOutSomethingsInput
      {
          SecretKey = "SecureKey",
          UserId = 100,
          SomethingIds = new List&lt;int&gt; { 10001, 1002, 1003 }
      }))
      .Returns&lt;List&lt;CheckedOutSomething&gt;&gt;((o) =&gt; new List&lt;CheckedOutSomething&gt;
      {
              new CheckedOutSomething { Id = 10001, Remarks = "Success" },
              new CheckedOutSomething  { Id = 10002, Remarks = "Success" }
      });
  
      var configuration = new MapperConfiguration(cfg =&gt;
      {
          cfg.AddSomething(new AutoMapperBusinessToEntitiesSomething());
          cfg.AddSomething(new AutoMapperModelsToBusinessSomething());
      });
  
      var mapper = new Mapper(configuration);
      var controller = new SomethingsController(checkoutServiceMock.Object, mapper);
  
      var result = controller.CheckOut(
          new CheckOutSomethingInputModel 
          { 
                UserId = 100, 
                SomethingIds = new List&lt;int&gt; { 10001, 10002, 10003 } 
          });
  
      Assert.IsType&lt;OkObjectResult&gt;(result.Result);
      Assert.Equal(2, result.Value.Count);
  }
  </code></pre>
  
  <blockquote>
    <p>Service
    <strong>Constructor</strong></p>
  </blockquote>
  
  <pre><code>public ProfilesController(ICheckoutService checkoutService, IMapper mapper)
  {
      this.checkoutService = checkoutService;
      this.mapper = mapper;            
  }
  </code></pre>
  
  <p><strong>Method</strong></p>
  
  <pre><code>[HttpPost]
  [Route("checkout")]
  public ActionResult&lt;List&lt;CheckedOutSomethingModel&gt;&gt; 
          CheckOut([FromBody] CheckOutSomethingInputModel checkoutInput)
  {       
      if (!ModelState.IsValid)
      {
          return BadRequest(ModelState);
      } 
  
      var input = mapper.Map&lt;CheckOutSomethingsInput&gt;(checkoutInput);
      var output = mapper.Map&lt;List&lt;CheckedOutSomethingModel&gt;&gt; 
      (checkoutService.CheckoutSomethings(input));
      return Ok(output);
  }
  </code></pre>
  
  <blockquote>
    <p>I cannot figure out what am I doing wrong </p>
  </blockquote>