Ejemplo n.º 1
0
        public void ConvertMovieListItemToQuickInfo_Poster_ReturnsValidMovieObject(string poster, string expectedPoster)
        {
            TheMovieDbApiOptions options = new TheMovieDbApiOptions()
            {
                PosterPath   = "http://path.com",
                NoPosterPath = "http://nopath.com"
            };
            var optionsMonitorMock = new Mock <IOptionsMonitor <TheMovieDbApiOptions> >();

            optionsMonitorMock.Setup(x => x.CurrentValue).Returns(options);
            var converter = new TheMovieDbConverter(optionsMonitorMock.Object);

            MovieGeneralInfo movieGeneralInfo = new MovieGeneralInfo()
            {
                Adult            = false,
                BackdropPath     = "/srYya1ZlI97Au4jUYAktDe3avyA.jpg",
                GenreIds         = new int[] { 14, 28, 12 },
                Id               = 464052,
                OriginalLanguage = "en",
                OriginalTitle    = "Wonder Woman 1984",
                Overview         = "Wonder Woman comes into conflict with the Soviet Union during the Cold War in the 1980s and finds a formidable foe by the name of the Cheetah.",
                Popularity       = 4749.437,
                PosterPath       = poster,
                ReleaseDate      = new DateTime(2020, 12, 16),
                Title            = "Wonder Woman 1984",
                Video            = false,
                VoteAverage      = 7.2,
                VoteCount        = 2385
            };
            MovieQuickInfo movieQuickInfo = new MovieQuickInfo()
            {
                MovieId     = 464052,
                IsFavorite  = false,
                Title       = "Wonder Woman 1984",
                ReleaseYear = 2020,
                Rank        = 7.2,
                Poster      = expectedPoster
            };
            var result = converter.ConvertMovieListItemToQuickInfo(movieGeneralInfo);

            Assert.AreEqual(movieQuickInfo.MovieId, result.MovieId);
            Assert.AreEqual(movieQuickInfo.Title, result.Title);
            Assert.AreEqual(movieQuickInfo.ReleaseYear, result.ReleaseYear);
            Assert.AreEqual(movieQuickInfo.Rank, result.Rank);
            Assert.AreEqual(movieQuickInfo.Poster, result.Poster);
        }
Ejemplo n.º 2
0
        public MovieQuickInfo ConvertMovieListItemToQuickInfo(MovieGeneralInfo movie)
        {
            if (movie == null)
            {
                return(null);
            }

            var result = new MovieQuickInfo()
            {
                MovieId     = movie.Id,
                Title       = movie.Title,
                Rank        = movie.VoteAverage,
                ReleaseYear = movie.ReleaseDate?.Year,
                Poster      = string.IsNullOrEmpty(movie.PosterPath) ? movieDbOptions.NoPosterPath : movieDbOptions.PosterPath + movie.PosterPath
            };

            return(result);
        }