public Task <IPagedCollection <Movie> > GetMovies(MovieOptions options) { if (options is null) { throw new ArgumentNullException(nameof(options)); } var filter = _filter .ClearFilters() .WhereCastInAny(options.Cast) .WhereDirectorsInAny(options.Directors) .WhereGenresInAny(options.Genres) .WhereRatedEquals(options.Rated) .WhereRuntime(options.Runtime) .WhereTitleLike(options.Title) .WhereTypeEquals(options.Type) .WhereYear(options.Year) .BuildAsLogicalAnd(); var sortDefinition = _sorter.SortBy(options.SortBy); return(_collection .Find(filter) .Sort(sortDefinition) .ToPagedCollectionAsync(options.PageNumber, options.PageSize)); }
static void SetMovieOptions(MovieOptions options) { SetVideoItemOptions(options); options.StorageMedium = "30"; options.DvdRegionCode = 31; options.ChannelName = "32"; options.ScheduledStartTimes = new[] { DateTime.Now }; options.ScheduledEndTimes = new[] { DateTime.Now + new TimeSpan(0, 0, 10) }; }
public void MovieInstantiation() { var options = new MovieOptions(); SetMovieOptions(options); var movie = new Movie("-1", "-1", options); AssertMovie(movie, options); AssertMovie(movie, movie.GetOptions()); }
static void AssertMovie(Movie movie, MovieOptions options) { AssertVideoItem(movie, options); Assert.AreEqual(movie.StorageMedium, options.StorageMedium); Assert.AreEqual(movie.DvdRegionCode, options.DvdRegionCode); Assert.AreEqual(movie.ChannelName, options.ChannelName); Assert.IsTrue(movie.ScheduledStartTimes.IsReadOnly); Assert.IsTrue(movie.ScheduledEndTimes.IsReadOnly); CollectionAssert.AreEqual(movie.ScheduledStartTimes, options.ScheduledStartTimes); CollectionAssert.AreEqual(movie.ScheduledEndTimes, options.ScheduledEndTimes); }
public async Task <IActionResult> ListMovies([FromQuery] MovieOptions options) { var response = await _movieService.GetMovieListAsync(new Services.GetMovieListRequest { Options = _mapper.Map <Services.MovieOptions>(options) }); return(this.OkWithPageHeader( items: _mapper.Map <IPagedCollection <Movie> >(response), routeName: nameof(ListMovies), queryParams: options, urlHelper: Url)); }
public async Task Should_get_list_of_movies() { // arrange var dao = _services.GetRequiredService <IMovieDao>(); var movies = new List <Movie>(); var page = new PagedCollection <Movie>(1, 2000) as IPagedCollection <Movie>; // act for (var pageCount = 0; pageCount < 10; pageCount++) { var options = MovieOptions.Empty( pageNumber: page.NextPageNumber ?? page.CurrentPageNumber, pageSize: page.PageSize); page = await dao.GetMovies(options).ConfigureAwait(true); movies.AddRange(page); } // assert Assert.Equal(20000, movies.Count); }
public MovieMakerHelper(MovieOptions options) { this.Options = options; }