public async Task Top_Search_Result() { var movieService = new OmdbService(); var result = await movieService.FirstSearchResultAsync("westworld").ConfigureAwait(false); Assert.IsNotNull(result); }
public void OmdbMovieInfoNotFoundExceptionTest() { OmdbService Service = OmdbService.Service; title = "thisIsNotAnameOfAmovie"; Service.GetMovieInfo(title); }
public async Task Search_Returns_Show() { var movieService = new OmdbService(); var result = await movieService.SearchAsync("westworld").ConfigureAwait(false); Assert.IsNotNull(result); }
public async Task Get_All_Seasons() { var movieService = new OmdbService(); var result = await movieService.GetAllSeasonsAsync("tt0475784").ConfigureAwait(false); Assert.IsNotNull(result); }
public void Initialize() { StructureMapConfigureTest.Initialize(); _configurationsFactory = StructureMapConfigureTest.Container.GetInstance <IConfigurationsFactory>(); _omdbService = new OmdbService(_configurationsFactory); }
public async void CanRetrieveMoviesByName() { // Arrange - Create an instance of the OmdbService OmdbService target = new OmdbService(); // Act - Request different results var resultPage1 = await target.GetByName("Jurassic"); var resultPage2 = await target.GetByName("Jurassic", 2); var resultEmpty = await target.GetByName("a1z0b2y9c3x8d4w7e5v6"); // Assert - Pages Assert.NotEmpty(resultPage1.Search); Assert.Equal(1, resultPage1.CurrentPage); Assert.NotEmpty(resultPage2.Search); Assert.Equal(2, resultPage2.CurrentPage); Assert.InRange(int.Parse(resultPage1.totalResults), 1, int.MaxValue); Assert.NotEqual(resultPage1.Search[0], resultPage2.Search[0]); Assert.Equal(resultPage1.totalResults, resultPage2.totalResults); // Assert - Empty Assert.Null(resultEmpty); }
public void OmdbTitleNotFoundExceptionTest() { OmdbService Service = OmdbService.Service; title = "thisIsNotAnameOfAmovie"; Service.SearchMovie(title); }
public async Task Get_Show_By_Id() { var movieService = new OmdbService(); var result = await movieService.GetShowByIdAsync("tt0475784").ConfigureAwait(false); Assert.IsNotNull(result); }
public void OmdbGetMovieInfoTest() { OmdbService Service = OmdbService.Service; title = "The matrix"; MovieInfo Expected = new MovieInfo(); Expected.Title = "The Matrix"; Expected.Year = "1999"; Expected.Rated = "R"; Expected.Released = "31 Mar 1999"; Expected.RunTime = "136 min"; Expected.Genre = "Action, Sci-Fi"; Expected.Director = "Andy Wachowski, Lana Wachowski"; Expected.Writer = "Andy Wachowski, Lana Wachowski"; Expected.Actors = "Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, Hugo Weaving"; Expected.Plot = "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers."; Expected.Language = "English"; Expected.Country = "USA, Australia"; Expected.Awards = "Won 4 Oscars. Another 33 wins & 40 nominations."; Expected.Rating = "8.7"; MovieInfo Actual = Service.GetMovieInfo(title); Assert.AreEqual(Expected, Actual); }
public GetWatchlistHandler( OmdbService omdbService, IServiceProvider serviceProvider ) { this.omdbService = omdbService; this.serviceProvider = serviceProvider; }
public DeleteMovieHandler( OmdbService omdbService, IServiceProvider serviceProvider ) { this.omdbService = omdbService; this.serviceProvider = serviceProvider; }
public GenerateRandomPicksHandler( OmdbService omdbService, IServiceProvider serviceProvider ) { this.omdbService = omdbService; this.serviceProvider = serviceProvider; }
public AddEventHandler( OmdbService omdbService, IServiceProvider serviceProvider ) { this.omdbService = omdbService; this.serviceProvider = serviceProvider; }
static void Main(string[] args) { var tmdb = new TmdbService(); var omdb = new OmdbService(); var movieService = new MovieService(); if (tmdb.IsDataEnd()) { Console.WriteLine("Data is the latest!"); return; } //從上次的頁數開始 int currentPage = tmdb.GetStartPage(); PopularMovieViewModel tmdbMovie = tmdb.GetPopularMovie(currentPage); int?totalPages = tmdbMovie?.Total_pages; List <tmpMovieModel> awaitingInsertDatas = new List <tmpMovieModel>(); while (totalPages.HasValue && currentPage <= totalPages) { foreach (var popurlarMovie in tmdbMovie.Results) { //利用tmdb去抓omdb的資料 var omdbMovie = omdb.SearchByTitle(popurlarMovie.title); if (omdbMovie != null && omdbMovie.Search != null) { awaitingInsertDatas.AddRange( omdbMovie.Search.Select(m => m.ReturnInjectObjectNullable <tmpMovieModel>()) ); } Console.WriteLine(popurlarMovie.title); if (awaitingInsertDatas.Count >= 100) { movieService.bulkInsert(awaitingInsertDatas); awaitingInsertDatas.Clear(); } } currentPage++; tmdbMovie = tmdb.GetPopularMovie(currentPage); } //剩下的再做一次 movieService.bulkInsert(awaitingInsertDatas); //將 temp的資料全部轉移 movieService.TransferDataFromTempTable(); Console.WriteLine("done"); }
public void OmdbSearchMovieByTitleTest() { OmdbService Service = OmdbService.Service; title = "Fight Club"; SearchResult Expected = new SearchResult(); SearchResult Actual = Service.SearchMovie(title); Assert.IsTrue(Actual.Titles.Contains("Fight Club") && Actual.Years.Contains("1999")); }
public async void CanRetrieveMovieById() { // Arrange - Create an instance of the OmdbService OmdbService target = new OmdbService(); // Act - Request movies Movie validMovie = await target.GetById("tt0107290"); Movie invalidMovie = await target.GetById("NotAnId"); // Assert - Valid Movie Assert.Equal("tt0107290", validMovie.imdbID); Assert.Equal("Jurassic Park", validMovie.Title); Assert.Equal("1993", validMovie.Year); Assert.Equal("Universal Pictures", validMovie.Production); // Assert - Invalid Movie Assert.Null(invalidMovie); }
private void InitializeObjects() { _omdbSettings = new OmdbSettings { ApiKey = "apiKey" }; _service = new OmdbService(_omdbSettings, _httpService.Object); _movieDoesntExistTitle = "movie-doesnt-exist"; _movieExistsTitle = "movie-exists"; _invalidHttpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest }; _validHttpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"Title\":\"Desperados\",\"Year\":\"2007–\",\"Rated\":\"N/A\",\"Released\":\"31 Jan 2007\",\"Runtime\":\"30 min\",\"Genre\":\"Drama, Family\",\"Director\":\"N/A\",\"Writer\":\"Paul Smith\",\"Actors\":\"Ade Adepitan, Cole Edwards, David Proud, Duane Henry\",\"Plot\":\"Desperados is a children's drama about a wheelchair basketball team. Following an accident which leaves him disabled, Charlie finds new meaning to his life when he joins the Desperados team.\",\"Language\":\"English\",\"Country\":\"UK\",\"Awards\":\"1 win & 1 nomination.\",\"Poster\":\"https://m.media-amazon.com/images/M/MV5BYWJhZmFhZTktNTg2Zi00YzU3LTg1YjgtYmM3YWVlMmE3NDNlXkEyXkFqcGdeQXVyMzUyOTk3NjQ@._V1_SX300.jpg\",\"Ratings\":[{\"Source\":\"Internet Movie Database\",\"Value\":\"8.0/10\"}],\"Metascore\":\"N/A\",\"imdbRating\":\"8.0\",\"imdbVotes\":\"37\",\"imdbID\":\"tt1039167\",\"Type\":\"series\",\"totalSeasons\":\"1\",\"Response\":\"True\"}") }; }
public ViewModule(NominationsService ns, OmdbService os, VotingService vs) { _nominationsService = ns; _omdbService = os; _votingService = vs; }
public ImdbSearchHandler( OmdbService omdbService) { this.omdbService = omdbService; }
public InfoModule(OmdbService omdbService) { _omdbService = omdbService; }
public FilmController(OmdbService omdbService) { _omdbService = omdbService; }
public async Task Omdb(CommandContext ctx, [Description("Movie or TV show to find on OMDB.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = OmdbService.GetMovieListAsync(Program.Settings.Tokens.OmdbToken, query.Replace(" ", "+")) .Result; if (!results.Search.Any()) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var title in results.Search) { var movie = OmdbService .GetMovieDataAsync(Program.Settings.Tokens.OmdbToken, title.Title.Replace(" ", "+")).Result; var output = new DiscordEmbedBuilder() .WithTitle(movie.Title) .WithDescription(movie.Plot.Length < 500 ? movie.Plot : movie.Plot.Take(500) + "...") .AddField("Released", movie.Released, true) .AddField("Runtime", movie.Runtime, true) .AddField("Genre", movie.Genre, true) .AddField("Rating", movie.Rated, true) .AddField("IMDb Rating", movie.IMDbRating, true) .AddField("Box Office", movie.BoxOffice, true) .AddField("Directors", movie.Director) .AddField("Actors", movie.Actors) .WithFooter(!movie.Title.Equals(results.Search.Last().Title) ? "Type 'next' within 10 seconds for the next movie." : "This is the last found movie on OMDB.") .WithColor(DiscordColor.Goldenrod); if (movie.Poster != "N/A") { output.WithImageUrl(movie.Poster); } var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Search.Length == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!movie.Title.Equals(results.Search.Last().Title)) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public void GetMovieData() { Assert.IsNotNull(OmdbService.GetMovieDataAsync(TestSetup.Tokens.OmdbToken, "office+space").Result); }
public VotingModule(VotingService votingService, NominationsService nominationsService, OmdbService omdbService) { _votingService = votingService; _nominationsService = nominationsService; _omdbService = omdbService; }
private async static Task <T> PerformAction <T>(Func <IDataService <Movie>, Task <T> > action) { //TODO: Create and use a service factory IDataService <Movie> service = new OmdbService(); return(service != null ? await action(service) : default);
public SeriesController(OmdbService omdbService) { _omdbService = omdbService; }