public void ChekingForCorrectCarModelById() { var request = new RestRequest("/cars/1"); var response = _restClient.Get(request); var currentCarModel = CarsModel.FromJson(response.Content); Assert.IsTrue(response.IsSuccessful); Assert.AreEqual("Ferrari", currentCarModel.Model); }
public void PatchExistingCar() { var newCar = new CarsModel() { Model = "Porshe", Year = 2002, HorsePower = 533, Engine = 6 }; var request = new RestRequest("/cars/1", Method.PATCH); request.AddParameter("application/json", newCar.ToJson(), ParameterType.RequestBody); IRestResponse response = _restClient.Execute(request); var actualCar = CarsModel.FromJson(response.Content); Assert.IsTrue(response.IsSuccessful); var expectedAuthor = new CarsModel() { Model = newCar.Model, Engine = newCar.Engine, Year = newCar.Year, }; Assert.AreEqual(actualCar.Model, expectedAuthor.Model); Assert.AreEqual(actualCar.Year, expectedAuthor.Year); }
public void CreateNewCar() { var newCar = new CarsModel() { Id = 1, Model = "Opel", Year = 1999, HorsePower = 150, Engine = 2 }; var request = new RestRequest("/cars", Method.POST); request.AddParameter("application/json", newCar.ToJson(), ParameterType.RequestBody); IRestResponse response = _restClient.Execute(request); var actualCar = CarsModel.FromJson(response.Content); Assert.IsTrue(response.IsSuccessful); var expectedAuthor = new CarsModel() { Model = newCar.Model, Engine = newCar.Engine, Year = newCar.Year, }; Assert.AreEqual(actualCar.Model, expectedAuthor.Model); Assert.AreEqual(actualCar.Year, expectedAuthor.Year); }