title: IHttpActionResult and Integration Testing Web API v2 Put in MS Test
body: <p>VS2013 auto generated a web api v2 controller for me based on my EF context.  I am trying to unit test the put part of the controller.  No matter what i do i can't get my asserts to check the StatusCodeResult return.  The auto generated code looks like this:</p>
  
  <pre><code> // PUT api/Vendor/5
      public IHttpActionResult PutVendor(int id, Vendor vendor)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          if (id != vendor.Id)
          {
              return BadRequest();
          }
  
          db.Entry(vendor).State = EntityState.Modified;
  
          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateConcurrencyException)
          {
              if (!VendorExists(id))
              {
                  return NotFound();
              }
              else
              {
                  throw;
              }
          }
  
          return StatusCode(HttpStatusCode.NoContent);
      }
  </code></pre>
  
  <p>My Integration test looks like this:</p>
  
  <pre><code>        [TestMethod]
      public void PutVendor_UpdateVendorRecord_ReturnsTrue()
      {
          // Arrange
          //CleanUpVendors();
  
          var controller = new VendorController(ctx);
          const string vendorName = "Unit Test Company";
  
          // Add vendor to database
          ctx.Vendors.Add(new Vendor { Active = true, Name = vendorName });
          ctx.SaveChanges();
  
          var myVendor = (from v in ctx.Vendors
                          where v.Name == vendorName
                          select v).FirstOrDefault();
  
          // Get Newly Inserted ID
          Assert.IsNotNull(myVendor, "Vendor is Null");
          myVendor.Name = "New Name";
  
          // Act
          var httpActionResult = controller.PutVendor(myVendor.Id, myVendor);
          //var response = httpActionResult as OkNegotiatedContentResult&lt;Vendor&gt;;
          var response = httpActionResult as OkNegotiatedContentResult&lt;Vendor&gt;;
  
          // Assert
  
  
      }
  </code></pre>
  
  <p>Is there something wrong with my test?  What should my Asserts look like?</p>
  
  <p>This assert returns true:</p>
  
  <pre><code>Assert.IsInstanceOfType(httpActionResult, typeof(System.Web.Http.Results.StatusCodeResult));
  </code></pre>
  
  <p>but I don't think it is actually testing anything except that there was some kind of return.  Any help would be greatly appreciated.</p>