예제 #1
0
        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);
        }
예제 #2
0
        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");
        }
예제 #3
0
        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);
        }