public async Task DeleteTruck_Exists_ReturnsOk() { // create model var model = new Model(); model.Description = Guid.NewGuid().ToString(); IActionResult actionResult = await _modelController.PostModel(model); var modelCreatedResult = actionResult as CreatedAtActionResult; Assert.IsNotNull(modelCreatedResult); Assert.AreEqual(201, modelCreatedResult.StatusCode); model.ModelId = Convert.ToInt32(modelCreatedResult.RouteValues["id"]); // create truck var truck = new Truck(); truck.Chassis = Guid.NewGuid().ToString(); truck.Year = Convert.ToInt16(new Random().Next(1900, 2019)); truck.Model = model; actionResult = await _truckController.PostTruck(truck); var createdResult = actionResult as CreatedAtActionResult; Assert.IsNotNull(createdResult); Assert.AreEqual(201, createdResult.StatusCode); // delete truck actionResult = await _truckController.DeleteTruck(truck.TruckId); var okResult = actionResult as OkObjectResult; Assert.IsNotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); Assert.Pass(); }