public void TestPutClaimAndAddNewVehicle() { string newClaimNumber = TestDataGenerator.GenerateUniqueClaimNumber(); MitchellClaim expectedClaim = TestDataGenerator.GetTestClaim(newClaimNumber); // Create a new claim HttpResponseMessage response = ClaimsController.Post(expectedClaim); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "A POST of a new claim should succeed."); // Prepare a claim "updater". MitchellClaim updater = new MitchellClaim(); updater.ClaimantLastName = "NewLastName"; expectedClaim.ClaimantLastName = updater.ClaimantLastName; // Note: The updater will have to include both vehicles that are changed and those who are not changed. // The vehicles that are not changed will only have the Vin field set. // This system enables us to delete vehicles with the update request. The tread-off is that when we // specify a list of vehicles then that list must include vehicles that are not changed. updater.Vehicles = new List <VehicleDetails>(); updater.Vehicles.Add(new VehicleDetails() { Vin = expectedClaim.Vehicles[0].Vin }); updater.Vehicles.Add(new VehicleDetails() { Vin = expectedClaim.Vehicles[1].Vin }); // We'll request a new vehicle to be added. However, this vehicle has required parameters that are not specified. VehicleDetails newVehicle = new VehicleDetails() { Vin = TestDataGenerator.GenerateUniqueVinNumber(), ModelYear = 2015, Mileage = 200 }; updater.Vehicles.Add(newVehicle); expectedClaim.Vehicles.Add(newVehicle.DeepClone()); // Update the claim. response = ClaimsController.Put(newClaimNumber, updater); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "A PUT of an existing claim should succeed."); // Retrieved the updated claim and compare it with the expected value. MitchellClaim retrievedClaim = ClaimsController.Get(newClaimNumber); Assert.AreEqual(expectedClaim.Vehicles.Count, 3, "Defensive check - making sure that the expected claim was setup correctly."); Assert.AreEqual(expectedClaim, retrievedClaim, "The claim that was created, updated and retrieved should have the expected values."); }