예제 #1
0
        public void GivenJsonStringOfMovies_WhenConstructed_ThenCountIsCorrect()
        {
            var movieStore = new MovieJsonStore();

            movieStore.LoadFromString(_movieJsonData);

            Assert.Equal(200, movieStore.GetCount());
        }
예제 #2
0
        public void GivenDataLoaded_WhenFilteredByOriginalLanguage_ThenCorrectNumberOfItemsReturned()
        {
            var movieStore = new MovieJsonStore();

            movieStore.LoadFromString(_movieJsonData);

            var englishMovies = movieStore.FilterByOriginalLanguage("JA").ToList();

            Assert.Equal(4, englishMovies.Count);
        }
예제 #3
0
        public void GivenDataLoaded_WhenMovieGotById_ThenCorrectMovieReturned()
        {
            var movieStore = new MovieJsonStore();

            movieStore.LoadFromString(_movieJsonData);

            var movie = movieStore.GetById(424694);

            Assert.Equal(424694, movie.Id);
            Assert.Equal("Bohemian Rhapsody", movie.Title);
        }
        public IActionResult Details(int id)
        {
            var movieStore = new MovieJsonStore();

            movieStore.LoadFromString(MovieResources.movies);

            var movie = movieStore.GetById(id);
            var model = new MovieViewModel
            {
                Id               = movie.Id,
                Title            = movie.Title,
                OriginalLanguage = movie.OriginalLanguage,
                ReleaseDate      = movie.ReleaseDate,
                VoteAverage      = movie.VoteAverage
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            var movieStore = new MovieJsonStore();

            movieStore.LoadFromString(MovieResources.movies);

            var models = movieStore.GetAll()
                         .Select(m =>
                                 new MovieViewModel
            {
                Id               = m.Id,
                Title            = m.Title,
                OriginalLanguage = m.OriginalLanguage,
                ReleaseDate      = m.ReleaseDate,
                VoteAverage      = m.VoteAverage,
                Overview         = m.Overview
            }).ToList();

            return(View(models));
        }