Example #1
0
        public void RecommendedMoviesUpdatedCorrectlyTest()
        {
            MovieDetailViewModel comparisonMovie = new MovieDetailViewModel(new Movie()
            {
                ItemID = "111"
            }, preferences);
            var task = viewModel.UpdateMovieRecommendations();

            Assert.AreEqual(1, viewModel.RecommendedMovies.Count);
            Assert.AreEqual(comparisonMovie, viewModel.RecommendedMovies[0]);
        }
Example #2
0
 public void BackendErrorWhenRequestingRecommendedMoviesTest()
 {
     try
     {
         var genreListTask = Task.FromResult <IDictionary <string, List <Movie> > >(popularMovies);
         faultyMockClient.Setup(x => x.GetPopularMovies(It.IsAny <List <Genre> >())).Returns(genreListTask);
         faultyMockClient.Setup(x => x.GetMovieRecommendationsFromPreferences(It.IsAny <UserMoviePreferences>())).Throws(new BadBackendRequestException());
         faultyViewModel = new BrowseViewModel(ex => { e = ex; exceptionHandled = true; }, preferences, faultyMockClient.Object);
         var task = faultyViewModel.UpdateMovieRecommendations();
     }
     catch
     {
         Assert.Fail();
     }
     Assert.IsTrue(exceptionHandled);
 }
Example #3
0
        public void EmptyRecommendedMoviesListReturnedTest()
        {
            var genreListTask         = Task.FromResult <IDictionary <string, List <Movie> > >(popularMovies);
            var recommendedMoviesTask = Task.FromResult <IList <Movie> >(new List <Movie>());

            faultyMockClient.Setup(x => x.GetPopularMovies(It.IsAny <List <Genre> >())).Returns(genreListTask);
            faultyMockClient.Setup(x => x.GetMovieRecommendationsFromPreferences(It.IsAny <UserMoviePreferences>())).Returns(recommendedMoviesTask);

            try
            {
                faultyViewModel = new BrowseViewModel(ex => { e = ex; exceptionHandled = true; }, preferences, faultyMockClient.Object);
                var task = faultyViewModel.UpdateMovieRecommendations();
            }
            catch
            {
                Assert.Fail();
            }

            Assert.IsFalse(exceptionHandled);
            Assert.AreEqual(0, faultyViewModel.RecommendedMovies.Count);
        }