public static void ValidDELETECategoryRequest(string Endpoint, int Id) { string JSONPayload = "{\"id\":0,\"name\":\"Engineering\"}"; var REST = new RESTClient(BaseURL); REST.AddNewCategory(Endpoint, JSONPayload); var APIValidresponse = REST.DeleteEntry(Endpoint + Id); //Check response status code Assert.AreEqual(204, (int)APIValidresponse.StatusCode, "Status Code 204 Expected."); //check response headers Assert.AreEqual("application/json", APIValidresponse.ContentType, "Response content-type Header error"); //Check response body Assert.IsEmpty(APIValidresponse.Content, "Response body is empty"); //Check category no longer available var APIResponse = REST.GetCategoryList(Endpoint); var CategoriesList = JsonConvert.DeserializeObject <List <ListOfCategories> >(APIResponse.Content); for (int i = 0; i < CategoriesList.Count; i++) { if (CategoriesList[i].Name == "Engineering") { Assert.Fail("Deleted category can still be viewed"); } } }
public static void InvalidDELETECategoryRequest(string Endpoint, int Id) { var REST = new RESTClient(BaseURL); var APIInvalidresponse = REST.DeleteEntry(Endpoint + Id); //Check category not found response status code Assert.AreEqual(404, (int)APIInvalidresponse.StatusCode, "Status Code 404 Expected."); //Check response body Assert.IsNotEmpty(APIInvalidresponse.Content, "Response body is not empty"); }