コード例 #1
0
        // happy path
        public async Task WhenCalledOnValidRatedMovie_ReturnsState()
        {
            bool    isFavorite  = false;
            bool    onWatchlist = false;
            decimal rating      = 9m;

            await _client.RateMovie(_settings.SessionId, rating, _movie);

            // Server side (TMDB WebAPI) needs this delay to propagate changes...
            await Task.Delay(2000);

            GetMovieDetailsWithAccountStatesResult response = await _client.GetMovieDetailsWithAccountStates(_settings.SessionId, id : _movie, retryCount : 0);

            _output.WriteLine($"TMDB server's response code {response.HttpStatusCode}");
            _output.WriteLine($"TMDB server's response message {response.Json}");

            AccountMovieStates states = response.ExtractAccountStates();

            PrintAccountMovieStates(states);

            Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            Assert.True(states.IsFavorite == isFavorite);
            Assert.True(states.Rating.Value == rating);
            Assert.True(states.OnWatchlist == onWatchlist);
        }
コード例 #2
0
        // wierd path
        public async Task WhenCalledWithInvalidMovieId_Returns_404NotFound()
        {
            GetMovieDetailsWithAccountStatesResult response = await _client.GetMovieDetailsWithAccountStates(_settings.SessionId, id : _invalidMovie, retryCount : 0);

            _output.WriteLine($"TMDB server's response code {response.HttpStatusCode}");
            Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.NotFound);
            Assert.Null(response.ExtractAccountStates());
        }
コード例 #3
0
        // wierd path
        public async Task WhenCalledWithInvalidSessionId_ReturnsMovieDetailsAnd_200OK()
        {
            _settings.SessionId = "invalidSessionId";

            GetMovieDetailsWithAccountStatesResult response = await _client.GetMovieDetailsWithAccountStates(_settings.SessionId, id : _movie, retryCount : 0);

            _output.WriteLine($"TMDB server's response code {response.HttpStatusCode}");

            Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            Assert.Null(response.ExtractAccountStates());
            _output.WriteLine($"Imdb id = {JsonConvert.DeserializeObject<MovieDetailModel>(response.Json).ImdbId}");
        }
コード例 #4
0
        // happy path
        public async Task WhenCalledOnValidMovie_ReturnsState()
        {
            bool isFavorite  = false;
            bool onWatchlist = false;

            GetMovieDetailsWithAccountStatesResult response = await _client.GetMovieDetailsWithAccountStates(_settings.SessionId, id : _movie, retryCount : 0);

            _output.WriteLine($"TMDB server's response code {response.HttpStatusCode}");
            _output.WriteLine($"TMDB server's response message {response.Json}");

            AccountMovieStates states = response.ExtractAccountStates();

            PrintAccountMovieStates(states);

            Assert.True(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
            Assert.True(states.IsFavorite == isFavorite);
            Assert.True(states.Rating == null);
            Assert.True(states.OnWatchlist == onWatchlist);
        }
コード例 #5
0
        public async Task <GetMovieDetailsWithAccountStatesResult> GetMovieDetailsWithAccountStates(string sessionId, int id, string language = null, int retryCount = 0, int delayMilliseconds = 1000)
        {
            string baseUrl = BASE_Address + BASE_Path + MOVIE_DETAILS_Path + "/" + id;

            var query = new Dictionary <string, string>();

            query.Add(API_KEY_Key, ApiKey);
            if (!string.IsNullOrEmpty(language))
            {
                query.Add(LANGUAGE_Key, language);
            }

            if (!string.IsNullOrEmpty(sessionId))
            {
                query.Add(SESSION_ID_Key, sessionId);
                query.Add(APPEND_RESPONSE_Key, ACCOUNT_STATES_Key);
            }

            string requestUri = QueryHelpers.AddQueryString(baseUrl, query);

            GetMovieDetailsWithAccountStatesResult result = await GetResponse <GetMovieDetailsWithAccountStatesResult>(retryCount, delayMilliseconds, requestUri);

            return(result);
        }