title: How to write unit test case for BadRequest?
body: <p>I want to write Unit test cases for following code</p>
  
  <p>HomeController.cs</p>
  
  <pre><code>[HttpPost]
          [ActionName("CreateDemo")]
          public async Task&lt;IHttpActionResult&gt; CreateDemo([FromBody] MyRequest request)
          {
              if (request == null)
              {                    
                  return BadRequest("request can not be null");
              }
              if (request.MyID == Guid.Empty)
              {
                  return BadRequest("MyID must be provided");
              }
          }
  </code></pre>
  
  <p>I tried like following which is not correct way i guess so</p>
  
  <pre><code> [TestMethod]
          public async Task NullCheck()
          {
              try
              {
                  var controller = new HomeController();
                  var resposne = await controller.CreateDemo(null);
                  Assert.AreEqual(); // not sure what to put here
              }
              catch (HttpResponseException ex) //catch is not hit
              {
                  Assert.IsTrue(
                       ex.Message.Contains("request can not be null"));
              }
  
          }
  </code></pre>