Example #1
0
        public void TestGetItemByTitleBad()
        {
            var omdb = new OmdbClient(TestData.apikey, true);

            Assert.Throws <ArgumentException>(() => omdb.GetItemByTitle(null));
            Assert.Throws <ArgumentException>(() => omdb.GetItemByTitle(""));
            Assert.Throws <ArgumentException>(() => omdb.GetItemByTitle(" "));
            Assert.Throws <ArgumentOutOfRangeException>(() => omdb.GetItemByTitle("star wars", 1500));
        }
Example #2
0
        public void TestGetItemByTitleGood2()
        {
            var omdb  = new OmdbClient(TestData.apikey, true);
            var movie = omdb.GetItemByTitle("Star Wars", OmdbType.Movie, 2017, false);

            var ratings = movie.Ratings.ToArray();

            Assert.Equal("Internet Movie Database", ratings[0].Source);
            Assert.Equal("Rotten Tomatoes", ratings[1].Source);
            Assert.Equal("Metacritic", ratings[2].Source);

            Assert.Equal("Star Wars: Episode VIII - The Last Jedi", movie.Title);
            Assert.Equal("2017", movie.Year);
            Assert.Equal("PG-13", movie.Rated);
            Assert.Equal("15 Dec 2017", movie.Released);
            Assert.Equal("152 min", movie.Runtime);
            Assert.Equal("Rian Johnson", movie.Director);
            Assert.Equal("English", movie.Language);
            Assert.Equal("USA", movie.Country);
            Assert.Equal("movie", movie.Type);
            Assert.Equal("http://www.rottentomatoes.com/m/star_wars_episode_viii/", movie.TomatoUrl);
            Assert.Equal("Walt Disney Pictures", movie.Production);
            Assert.Null(movie.TotalSeasons);
            Assert.Equal("True", movie.Response);
        }
Example #3
0
        public void TestGetItemByTitleGood1()
        {
            var omdb  = new OmdbClient(TestData.apikey);
            var movie = omdb.GetItemByTitle("Star Wars", true);

            var ratings = movie.Ratings.ToArray();

            Assert.Equal("Internet Movie Database", ratings[0].Source);
            Assert.Equal("Rotten Tomatoes", ratings[1].Source);
            Assert.Equal("Metacritic", ratings[2].Source);

            Assert.Equal("Star Wars: Episode IV - A New Hope", movie.Title);
            Assert.Equal("1977", movie.Year);
            Assert.Equal("PG", movie.Rated);
            Assert.Equal("25 May 1977", movie.Released);
            Assert.Equal("121 min", movie.Runtime);
            Assert.Equal("George Lucas", movie.Director);
            Assert.Equal("George Lucas", movie.Writer);
            Assert.Equal("English", movie.Language);
            Assert.Equal("USA", movie.Country);
            Assert.Equal("tt0076759", movie.ImdbId);
            Assert.Equal("movie", movie.Type);
            Assert.Equal("21 Sep 2004", movie.Dvd);
            Assert.Equal("20th Century Fox", movie.Production);
            Assert.Equal("http://www.starwars.com/episode-iv/", movie.Website);
            Assert.Null(movie.TotalSeasons);
            Assert.Equal("True", movie.Response);
        }
Example #4
0
 private void Display_Online_Info_Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (IsNetworkAvailable)
         {
             if (m_lastFocusedTitle != null && m_lastFocusedTitle != "")
             {
                 OmdbClient  _client   = new OmdbClient(MyConsts.API_KEY);
                 Item        _responce = _client.GetItemByTitle(m_lastFocusedTitle, true);
                 DisplayInfo display   = new DisplayInfo(_responce);
                 display.ShowDialog();
             }
             else
             {
                 DisplayInfo display = new DisplayInfo();
                 display.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("No internet connetction found...", "Could not find a connection", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     catch (Exception EX)
     {
         MessageBox.Show($"{EX.Message}", "Title Not Found \nPlease enter a valid Title", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        /// <inheritdoc />
        public override List <BasicInfo> GetResponse(List <string> entities, bool outputResults)
        {
            // Use HashSet to avoid duplicated data which can produce errors in further work.
            var searchResults = new HashSet <BasicInfo>();

            foreach (string movie in entities)
            {
                Item response;
                try
                {
                    response = _omdbClient.GetItemByTitle(movie);
                }
                catch (Exception ex)
                {
                    _logger.Warn(ex, $"{movie} wasn't processed.");
                    GlobalMessageHandler.OutputMessage($"{movie} wasn't processed.");
                    continue;
                }

                if (!response.Response.IsEqualWithInvariantCulture("True"))
                {
                    _logger.Warn($"{movie} wasn't processed.");
                    GlobalMessageHandler.OutputMessage($"{movie} wasn't processed.");
                    continue;
                }

                // Get first search result from response and ignore all the rest.
                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage($"Got {response.Title} from {Tag}");
                }

                OmdbMovieInfo extractedInfo = _dataMapper.Transform(response);
                searchResults.Add(extractedInfo);
            }
            return(searchResults.ToList());
        }
Example #6
0
        public void TestGetItemByTitleGood3()
        {
            var omdb  = new OmdbClient(TestData.apikey, true);
            var movie = omdb.GetItemByTitle("Arrow", OmdbType.Series, 2012, false);

            var ratings = movie.Ratings.ToArray();

            Assert.Equal("Internet Movie Database", ratings[0].Source);

            Assert.Equal("Arrow", movie.Title);
            Assert.Equal("2012–", movie.Year);
            Assert.Equal("TV-14", movie.Rated);
            Assert.Equal("10 Oct 2012", movie.Released);
            Assert.Equal("42 min", movie.Runtime);
            Assert.Equal("N/A", movie.Director);
            Assert.Equal("English", movie.Language);
            Assert.Equal("USA", movie.Country);
            Assert.Equal("series", movie.Type);
            Assert.Equal("N/A", movie.Dvd);
            Assert.Equal("N/A", movie.BoxOffice);
            Assert.Equal("N/A", movie.Production);
            Assert.Equal("N/A", movie.Website);
            Assert.Equal("True", movie.Response);
        }
Example #7
0
        public void TestGetItemByTitleBad2()
        {
            var omdb = new OmdbClient(TestData.apikey, true);

            Assert.Throws <HttpRequestException>(() => omdb.GetItemByTitle("Skyrim", OmdbType.Game));
        }