예제 #1
0
        public void GetMovieDetailsSuccess1()
        {
            /*
             * Assert that the GET movie endpoint receives a 200 response, verify response body
             * 1.  Send call to get endpoint 3/movie/{movieId}?api_key={apiKey}&language=en-US where movie id is 274
             * 2.  Assert that response code is 200
             * 3.  Assert that the movie title is correct
             */
            //new requests object
            APIs api = new APIs();
            //send get call with appropriate endpoint and apikey
            //var response = requests.Get(Endpoint: string.Format(@"3/movie/{0}?api_key={1}&language=en-US", "274", apiKey));
            var response = api.Movies.MovieDetails(MovieId: "274").Get();
            MovieDetailsResponse detailsObject = null;

            try
            {
                //deserialize json response
                detailsObject = JsonConvert.DeserializeObject <MovieDetailsResponse>(response.Content.ReadAsStringAsync().Result);
            }
            catch (JsonReaderException jsonEx)
            {
                //fail test if deserialization fails
                Assert.Fail(string.Format("Unable to deserialize response.  Exception: {0}"), jsonEx);
            }
            //assert that response has a 200 OK code
            Assert.AreEqual(200, (int)response.StatusCode);
            //assert that the movie title is correct in the response body
            Assert.AreEqual("The Silence of the Lambs", detailsObject.title);
        }
예제 #2
0
 public Requests(APIs API, string Endpoint)
 {
     this.api      = API;
     this.endpoint = Endpoint;
 }