title: Testing the Patch odata webapi method
body: <p>I need to test the following Patch method in my odata controller from my test project.</p>
  
  <pre><code>[ValidateModel]
          [AcceptVerbs("PATCH", "MERGE")]
          public async Task&lt;IHttpActionResult&gt; Patch([FromODataUri] int key, Delta&lt;User&gt; patch)
          {
              var user = await db.Users.FindAsync(key);
              if (user == null)
              {
                  return NotFound();
              }
  
              patch.Patch(user);
  
              Validate(user);
  
              if (!ModelState.IsValid)
              {
                  return BadRequest(ModelState);
              }
  
              try
              {
                  db.Entry(user).Property(p =&gt; p.UserType).IsModified = false;
                  await db.SaveChangesAsync();
              }
              catch (DbUpdateConcurrencyException)
              {
                  if (!UserExists(key))
                  {
                      return NotFound();
                  }
                  throw;
              }
  
              return Updated(user);
          }
  </code></pre>
  
  <p>The code in the test project is as follows. Could someone tell me how do I pass value to the Delta parameter. Currently I am getting compilation errors at line  controller.Patch(1,   user);.</p>
  
  <pre><code>[TestMethod]
          public void TestPatch()
          {
              // Arrange
              var controller = new UsersController();
  
              var user = new User();
              user.Id = 1;
              user.Lastname = "Johanson";
              // Act
              controller.Patch(1,  &lt;System.Web.OData.Delta&gt; user);
  
              // Assert
          }
  </code></pre>