title: Unit testing test for Ok Result
body: <p>I have the following (simplified) controller:</p>
  
  <pre><code>public async Task&lt;IHttpActionResult&gt; Profile(UpdateProfileModelAllowNulls modelNullable)
  {         
      ServiceResult&lt;ProfileModelDto&gt; result = await _profileService.UpdateProfile(1);
  
      return Ok(result);         
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>public async Task&lt;ServiceResult&lt;ProfileModelDto&gt;&gt; UpdateProfile(ApplicationUserDto user, UpdateProfileModel profile)
  {
       //Do something...
  }
  </code></pre>
  
  <p>and the following NUnit test:</p>
  
  <pre><code>[Test]
          public async Task Post_Profile()
          {
              var result = _controller.Profile(new UpdateProfileModelAllowNulls() { Email = "testEmail@tt.co.uk", DisplayName = "TestDisplay"}) as OkNegotiatedContentResult&lt;Task&lt;&lt;ProfileModelDto&gt;&gt;;
              Assert.IsNotNull(result);            
          }
  </code></pre>
  
  <p>In my NUnit test, I am trying to check for an Ok result using this tutorial <a href="https://www.asp.net/web-api/overview/testing-and-debugging/unit-testing-with-aspnet-web-api" rel="nofollow noreferrer">https://www.asp.net/web-api/overview/testing-and-debugging/unit-testing-with-aspnet-web-api</a>.</p>
  
  <p>My problem is that I cannot convert to an <code>OkNegotiatedContentResult</code>, i assume because I am not passing in the correct object, but I cannot see what object I should be passing in. As far as I can see, I am passing in the correct object eg: <code>OkNegotiatedContentResult&lt;Task&lt;&lt;ProfileModelDto&gt;&gt;;</code></p>
  
  <p>but this does not work.</p>
  
  <p>I have also tried:</p>
  
  <pre><code>var result = _controller.Profile(new UpdateProfileModelAllowNulls() { Email = "testEmail@tt.co.uk", DisplayName = "TestDisplay"}) as OkNegotiatedContentResult&lt;Task&lt;IHttpActionResult&gt;&gt;;
  </code></pre>
  
  <p>But this does not work either.</p>
  
  <p>Can anyone help?</p>