public void GetMakeCount() { var config = new ConfigurationBuilder().AddJsonFile("testConfig.json").Build(); var _uri = config["URI"]; RestClient restClient = new RestClient(_uri); RestRequest restRequest = new RestRequest(Method.GET); IRestResponse restResponse = restClient.Execute(restRequest); string responseBody = restResponse.Content; CarsResponse carsResponse = JsonConvert.DeserializeObject <CarsResponse>(responseBody); int numMakes = carsResponse.Makes.Count; _test.Info("Total number of car makes is " + numMakes); }
public void VerifyMakeExists() { var config = new ConfigurationBuilder().AddJsonFile("testConfig.json").Build(); var _uri = config["URI"]; var carBrand = config["existingBrand"]; RestClient restClient = new RestClient(_uri); RestRequest restRequest = new RestRequest(Method.GET); IRestResponse restResponse = restClient.Execute(restRequest); string responseBody = restResponse.Content; CarsResponse carsResponse = JsonConvert.DeserializeObject <CarsResponse>(responseBody); List <Make> makes = carsResponse.Makes; bool brandExists = makes.Exists(x => x.MakeName == carBrand); Assert.True(brandExists); _test.Info($"{ carBrand } exists as a make"); }
public void GetCarCountForBrand() { var config = new ConfigurationBuilder().AddJsonFile("testConfig.json").Build(); var _uri = config["URI"]; var carBrand = config["existingBrand"]; RestClient restClient = new RestClient(_uri); RestRequest restRequest = new RestRequest(Method.GET); IRestResponse restResponse = restClient.Execute(restRequest); string responseBody = restResponse.Content; CarsResponse carsResponse = JsonConvert.DeserializeObject <CarsResponse>(responseBody); List <Make> makes = carsResponse.Makes; var carInstance = makes.Find(x => x.MakeName.Equals(carBrand)); int carCount = carInstance.Count; _test.Info($"Number of cars listed for { carBrand } is " + carCount); }