public void Can_Update_Existing_Student_Info() { Student postData = new Student() { FirstName = "testFirstName", LastName = "testLastName", Email = "*****@*****.**", Phone = "3939992222", isActive = true }; // Add a test data to DB _studentDbContext.Students.Add(postData); _studentDbContext.SaveChanges(); Student updatedData = new Student() { FirstName = "xxxFirstName", LastName = "xxxLastName", Email = "*****@*****.**", Phone = "0000000000", isActive = false }; updatedData.StudentId = postData.StudentId; endPoint = _baseUrl + "/" + updatedData.StudentId; var jsonData = JsonConvert.SerializeObject(updatedData); headers.Add("content-type", "application/json"); // Update the test data var result = API_Helper.PutRequest(endPoint, headers, jsonData); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); // Get the updated data from DB var fromDB = _studentDbContext.Students.Where(s => s.StudentId == updatedData.StudentId).FirstOrDefault(); // Refresh DbContext so that it has the most updated data. (((IObjectContextAdapter)_studentDbContext).ObjectContext).Refresh(RefreshMode.StoreWins, fromDB); Assert.IsTrue(updatedData.stEquals(fromDB)); }