public void CreateNewOrderTest() { RestClient client = new RestClient(PetStoreRestAPIData.petStoreAPIUrl); RestRequest request = new RestRequest(PetStoreRestAPIData.createNewOrderRequest, Method.POST); request.AddParameter("application/json", PetStoreRestAPIData.ReadInfoFromTheFile(PetStoreRestAPIData.pathToNewOrderFile), ParameterType.RequestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.Content.Contains(PetStoreRestAPIData.createNewOrderResult)); }
public void UpdateCreatedPet() { var client = new RestClient(PetStoreRestAPIData.petStoreAPIUrl); var request = new RestRequest(PetStoreRestAPIData.createNewPetRequest, Method.PUT); request.AddParameter("application/json", PetStoreRestAPIData.ReadInfoFromTheFile(PetStoreRestAPIData.pathToUpdatePetFile), ParameterType.RequestBody); IRestResponse response = client.Execute(request); var content = response.Content; Console.WriteLine($"Content : {content}"); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(content.Contains(PetStoreRestAPIData.updatePetResult)); }
public void DeleteOrderByIdTest() { RestClient client = new RestClient(PetStoreRestAPIData.petStoreAPIUrl); RestRequest request = new RestRequest(PetStoreRestAPIData.createNewOrderRequest, Method.POST); request.AddParameter("application/json", PetStoreRestAPIData.ReadInfoFromTheFile(PetStoreRestAPIData.pathToNewOrderFile), ParameterType.RequestBody); IRestResponse response = client.Execute(request); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); request = new RestRequest(PetStoreRestAPIData.deleteOrderRequest, Method.DELETE); response = client.Execute(request); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); request = new RestRequest(PetStoreRestAPIData.findOrderRequest, Method.GET); response = client.Execute(request); Assert.IsTrue(response.Content.Contains(PetStoreRestAPIData.errorFindOrderMessage)); }