title: Detect BadRequest with a test
body: <p>I have two projects: Api and Api.Tests</p>
  
  <p>I want to send invalid DTOs to the API, and then check that I receive BadRequest (status code).</p>
  
  <p>My code:</p>
  
  <pre><code>var user = new UserDTO {...};
  IActionResult response = await new UsersController().Post(user);
  
  Assert.IsInstanceOfType(response, typeof(Microsoft.AspNetCore.Mvc.BadRequestResult));
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>--- End of stack trace from previous location where exception was thrown ---    at
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
    task) Result2 Message:    Assert.IsInstanceOfType failed.  Expected
    type:. Actual
    type:</p>
  </blockquote>
  
  <p>The error says I have received "Ok", but I have checked it with Postman, and I receive BadRequest.</p>