title: How to test response StatusCode of MVC Controller Action
body: <p>I want to write unit test for my controller.</p>
  
  <p>I want to check the response codes of actions. For example, Post action should return <code>201</code>, get should return <code>200</code>, etc.</p>
  
  <p>However, the Action method return <code>IActionResult</code>. How do I get response code from the <code>ActionResult</code>?</p>
  
  <pre><code> //setup
   MyController controller = CreateController&lt;MyController&gt;();
  
   //action
   var actionResult = controller.Post(dafXml);
  
   //assert
   ???
  </code></pre>
  
  <p>I don't want to check the type of action result since I care only about the status code. for example, <code>201</code> can be achieved by <code>CreatedAtAction</code>, <code>CreatedAtRoute</code> or with custom <code>ObjectResult</code>...</p>