public void FindTestAllRussianFilm()
 {
     const string title = "Питер FM";
     const string year = "2006";
     var target = new FilmSeach(title, year);
     const bool showOnlyRelatedFilms = false;
     var expected = new MovieResult() { ID = "252063", Title = "Питер FM", Year = "2006" };
     var actual = target.Find(showOnlyRelatedFilms);
     Assert.IsTrue(actual.Contains(expected));
 }
        public void FindTestRelatedInternationalFilmByRussianTitle()
        {
            const string title = "Вердикт за деньги";
            const string year = "2003";
            const bool showOnlyRelatedFilms = true;

            var target = new FilmSeach(title, year);
            var expected = new List<MovieResult> { new MovieResult() { ID = "3621", Title = "Вердикт за деньги", Year = "2003" } };
            var actual = target.Find(showOnlyRelatedFilms);
            CollectionAssert.AreEqual(expected, actual);
        }
        public void FindTestRelatedInternationalFilm()
        {
            const string title = "Under Siege"; // why not :)
            const string year = "1992";
            const bool showOnlyRelatedFilms = true;

            var target = new FilmSeach(title, year);
            var expected = new List<MovieResult> {new MovieResult() {ID = "4053", Title = "Under Siege", Year = "1992"}};
            var actual = target.Find(showOnlyRelatedFilms);
            CollectionAssert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Searches for media by title.  Year is provided but is not typically used because Media
        /// Center Master will automatically negotiate matches by year.  Some fetchers will need to
        /// submit this data during lookup, though, so it is provided for that purpose.
        /// 
        /// A full result list is sent back to Media Center Master and it is Media Center Master's
        /// role to evaluate the list and make a decision on what to do with the data.
        /// 
        /// Required for:
        ///     meta data fetches (all)
        /// </summary>
        /// <returns>A list of serialized MCM_Common.MovieResult objects</returns>
        public static List<string> SearchByTitleAndYear(string title, string year)
        {
            Utils.Logger(Tag + string.Format("<b>SearchByTitleAndYear</b> called with title = \"{0}\", year={1}", title, year));

            var search = new Kinopoisk.FilmSeach(title, year);
            var movies = new List<string>();
            try
            {
                var found = search.Find();
                if (found.Count == 0)
                {
                    Utils.Logger(Tag + "<b>SearchByTitleAndYear</b> no direct matches found. Returning all results.");
                    found = search.Find(false);
                }
                if (found.Count > 0)
                    found.ForEach(f => Utils.Logger(Tag + "Found #" + f.ID + ", \"" + f.Title + "\" (" + f.Year + ")"));
                movies = found.Select(Utils.SerializeObject).ToList();

            }
            catch(Kinopoisk.FetchException ex)
            {
                Utils.Logger(String.Format(Tag + "<color=#B00000><u><b>{0}</b></u></color>", ex.Message));
                if (ex.InnerException != null)
                {
                    Utils.Logger("MCM_Common.Utils.PageFetch() exception:\r\n" + ex.Message);
                    //Utils.Logger(Utils.GetAllErrorDetails(ex.InnerException));
                }

            }
            catch (Exception ex)
            {
                Utils.Logger(Utils.GetAllErrorDetails(ex));
            }
            if (movies.Count == 0)
            {
                Utils.Logger(Tag + "<color=#B00000><u>no results (by title)</u></color>");
            }
            return movies;
        }
 public void FindTestRelatedRussianFilmByGlobalTitle()
 {
     const string title = "Piter FM";
     const string year = "2006";
     var target = new FilmSeach(title, year);
     const bool showOnlyRelatedFilms = true;
     var expected = new List<MovieResult> { new MovieResult() { ID = "252063", Title = "Питер FM", Year = "2006" } };
     var actual = target.Find(showOnlyRelatedFilms);
     CollectionAssert.AreEqual(expected, actual);
 }
 public void FindTestRelatedRussianFilm()
 {
     const string title = "Берегись автомобиля";
     const string year = "1966";
     var target = new FilmSeach(title, year);
     const bool showOnlyRelatedFilms = true;
     var expected = new List<MovieResult> { new MovieResult() { ID = "46089", Title = "Берегись автомобиля", Year = "1966" } };
     var actual = target.Find(showOnlyRelatedFilms);
     CollectionAssert.AreEqual(expected, actual);
 }