Ejemplo n.º 1
0
        public void ConvertMovieWithVideosToMovieDetails_WithYoutubeTeaser_ReturnsValidDetails()
        {
            TheMovieDbApiOptions options = new TheMovieDbApiOptions()
            {
                YoutubeEmbed = "<iframe src=\"youtube.com/{video-id}\"/>"
            };
            var optionsMonitorMock = new Mock <IOptionsMonitor <TheMovieDbApiOptions> >();

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

            MovieWithVideosInfo movieWithVideosInfo = new MovieWithVideosInfo()
            {
                Videos = new ListData <VideoInfo>()
                {
                    Result = new System.Collections.Generic.List <VideoInfo>()
                    {
                        new VideoInfo()
                        {
                            Site = "YouTube",
                            Key  = "qwerty",
                            Type = "Teaser"
                        }
                    }
                }
            };
            MovieDetails movieDetails = new MovieDetails()
            {
                Teaser = "<iframe src=\"youtube.com/qwerty\"/>"
            };
            var result = converter.ConvertMovieWithVideosToMovieDetails(movieWithVideosInfo);

            Assert.AreEqual(movieDetails.Teaser, result.Teaser);
        }
Ejemplo n.º 2
0
        public void ConvertMovieWithVideosToMovieDetails_WithoutYoutubeTeaser_ReturnsValidDetails()
        {
            var optionsMonitorMock = new Mock <IOptionsMonitor <TheMovieDbApiOptions> >();

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

            MovieWithVideosInfo movieWithVideosInfo = new MovieWithVideosInfo()
            {
                Videos = new ListData <VideoInfo>()
                {
                    Result = new System.Collections.Generic.List <VideoInfo>()
                    {
                        new VideoInfo()
                        {
                            Site = "YouTube",
                            Key  = "qwerty",
                            Type = "Trailer"
                        }
                    }
                }
            };
            var result = converter.ConvertMovieWithVideosToMovieDetails(movieWithVideosInfo);

            Assert.IsNull(result.Teaser);
        }
Ejemplo n.º 3
0
        public void ConvertMovieWithVideosToMovieDetails_EmptyData_ReturnsNull()
        {
            var movieDbOptions = Mock.Of <IOptionsMonitor <TheMovieDbApiOptions> >();
            var converter      = new TheMovieDbConverter(movieDbOptions);
            var result         = converter.ConvertMovieWithVideosToMovieDetails(null);

            Assert.IsNull(result);
        }
Ejemplo n.º 4
0
        public void ConvertMovieWithVideosToMovieDetails_GeneralFields_ReturnsValidDetails()
        {
            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);

            MovieWithVideosInfo movieWithVideosInfo = new MovieWithVideosInfo()
            {
                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,
                ReleaseDate      = new DateTime(2020, 12, 16),
                Title            = "Wonder Woman 1984",
                Video            = false,
                VoteAverage      = 7.2,
                VoteCount        = 2385,
                Budget           = 200000000,
                Revenue          = 131400000,
                Homepage         = "https://www.warnerbros.com/movies/wonder-woman-1984",
                ImdbId           = "tt7126948",
                Runtime          = 151,
                Videos           = null
            };
            MovieDetails movieDetails = new MovieDetails()
            {
                Budget   = 200000000,
                Revenue  = 131400000,
                Website  = "https://www.warnerbros.com/movies/wonder-woman-1984",
                ImdbLink = "https://www.imdb.com/title/tt7126948",
                Duration = "02:31:00",
                Teaser   = null
            };
            var result = converter.ConvertMovieWithVideosToMovieDetails(movieWithVideosInfo);

            Assert.AreEqual(movieDetails.Budget, result.Budget);
            Assert.AreEqual(movieDetails.Revenue, result.Revenue);
            Assert.AreEqual(movieDetails.Website, result.Website);
            Assert.AreEqual(movieDetails.ImdbLink, result.ImdbLink);
            Assert.AreEqual(movieDetails.Duration, result.Duration);
            Assert.AreEqual(movieDetails.Teaser, result.Teaser);
            Assert.IsNotNull(result.General);
        }
Ejemplo n.º 5
0
        public async Task <MovieDetails> GetMovieDetails(string movieId)
        {
            var data = await fetchMoviesDb <MovieWithVideosInfo>("/movie/" + movieId, new Dictionary <string, string>()
            {
                { "append_to_response", "videos" }
            });

            var result    = converter.ConvertMovieWithVideosToMovieDetails(data);
            var favorites = movieRepository.GetFavorites();

            result.General.IsFavorite = favorites.Contains(result.General.MovieId.ToString());
            return(result);
        }