title: How to Unit Test with ActionResult<T>?
body: <p>I have a xUnit test like:</p>
  
  <pre><code>[Fact]
  public async void GetLocationsCountAsync_WhenCalled_ReturnsLocationsCount()
  {
      _locationsService.Setup(s =&gt; s.GetLocationsCountAsync("123")).ReturnsAsync(10);
      var controller = new LocationsController(_locationsService.Object, null)
      {
          ControllerContext = { HttpContext = SetupHttpContext().Object }
      };
      var actionResult = await controller.GetLocationsCountAsync();
      actionResult.Value.Should().Be(10);
      VerifyAll();
  }
  </code></pre>
  
  <p>Source is</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Get the current number of locations for a user.
  /// &lt;/summary&gt;
  /// &lt;returns&gt;A &lt;see cref="int"&gt;&lt;/see&gt;.&lt;/returns&gt;
  /// &lt;response code="200"&gt;The current number of locations.&lt;/response&gt;
  [HttpGet]
  [Route("count")]
  public async Task&lt;ActionResult&lt;int&gt;&gt; GetLocationsCountAsync()
  {
      return Ok(await _locations.GetLocationsCountAsync(User.APropertyOfTheUser()));
  }
  </code></pre>
  
  <p>The value of the result is null, causing my test to fail, but if you look at <code>ActionResult.Result.Value</code> (an internal property) it contains the expected resolved value.</p>
  
  <p>See the following screen capture of the debugger.
  <a href="https://i.stack.imgur.com/MscJr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MscJr.png" alt="enter image description here"></a></p>
  
  <p>How do I get the actionResult.Value to populate in a unit test?</p>