public void Test_GetAllMovies_handles_empty_result()
        {
            // Arrange
            var mockRepo = new Mock <IMovieProvider>();

            mockRepo.Setup(repo => repo.GetAllMovies())
            .ReturnsAsync(ListClasses.GetMockEmptyMovies());

            var controller = new MovieController(mockRepo.Object);

            // Act
            var actual = controller.GetAllMovies();

            //Assert
            Assert.True(actual.ToList().Count == 0);

            try
            {
                Assert.Throws <InvalidOperationException>(() => controller.GetAllMovies());
            }
            catch (AssertActualExpectedException exception)
            {
                Assert.Equal("(No exception was thrown)", exception.Actual);
            }
        }
Exemplo n.º 2
0
        public void GetAllMovies_ReturnsOk_ReturnsMovies()
        {
            // Act
            IHttpActionResult actionResult = _controller.GetAllMovies();
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <MovieModel> >;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.Greater(1, -1);
        }
Exemplo n.º 3
0
        private void ListAllMovies()
        {
            Console.Clear();
            for (int i = 0; i < 122; i++)
            {
                Console.Write("-");
            }
            for (int i = 0; i < 52; i++)
            {
                Console.Write(" ");
            }
            Console.WriteLine("SHOW ALL MOVIES!");
            for (int i = 0; i < 122; i++)
            {
                Console.Write("-");
            }

            List <Movie> movies = movieController.GetAllMovies();

            foreach (Movie movie in movies)
            {
                PrintMovies(movie);
            }
            this.ReturnToMainScreen();
        }
Exemplo n.º 4
0
        public async Task No_Movies_Found_When_Calling_Get_All_Movies()
        {
            const string notFoundKey    = "controllers.movie.error.no_movies_found";
            const string notFoundString = "This movie could not be found";

            mockStringLocaliser.Setup(s => s[It.Is <string>(c => c.Equals(notFoundKey))])
            .Returns(() => new LocalizedString(notFoundKey, notFoundString));
            var mockRepo = new Mock <IMovieRepository>();

            mockRepo.Setup(r => r.GetAllMovies()).Returns(Task.FromResult(new List <Movie>()));

            var movieController = new MovieController(mockRepo.Object, mockStringLocaliser.Object, mockMemoryCache.Object);

            var result = await movieController.GetAllMovies(null);

            ContentResult contentResult = result as ContentResult;

            Assert.NotNull(contentResult);
            Assert.Equal((int)HttpStatusCode.NotFound, contentResult.StatusCode);

            var resultContent = JObject.Parse(contentResult.Content);

            Assert.Equal(notFoundString, "" + resultContent["message"]);

            mockRepo.Verify(x => x.GetAllMovies(), Times.Once);
        }
Exemplo n.º 5
0
        public void GetAllMovieShouldSucessfullyInvokeService_WhenCalled()
        {
            var mockMovieService = new Mock <IMovieService>();
            var mockRoleService  = new Mock <IRoleService>();
            var mockMapper       = new Mock <IMapper>();
            var mockFactory      = new Mock <IMovieModelFactory>();

            var controller = new MovieController(mockMovieService.Object,
                                                 mockRoleService.Object, mockMapper.Object, mockFactory.Object);

            // Act
            controller.GetAllMovies();

            // Assert
            mockMovieService.Verify(x => x.GetAllMovies(), Times.Once);
        }
Exemplo n.º 6
0
        public static async Task <ObservableCollection <Movie> > GetAllMoviesAsync(ObservableCollection <Movie> cache)
        {
            using (HttpResponseMessage response = await MovieController.GetAllMovies())
            {
                int    status = (int)response.StatusCode;
                string body   = await response.Content.ReadAsStringAsync();

                if (status == 200)
                {
                    ObservableCollection <MovieResponse> jsonBody = JsonConvert.DeserializeObject <ObservableCollection <MovieResponse> >(body);

                    try
                    {
                        return(await MovieResponseToMovie(jsonBody, cache));
                    }
                    catch (ServerException e)
                    {
                        throw e;
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
                else if (status == 400)
                {
                    throw new Exception(body);
                }
                else if (status == 401)
                {
                    throw new UnauthenticatedException();
                }
                else if (status == 404)
                {
                    return(new ObservableCollection <Movie>());
                }
                else if (status == 500)
                {
                    throw new ServerException();
                }
                else
                {
                    throw new Exception("An error occurred");
                }
            }
        }
        public void Test_GetAllMovies_Returns_MovieListItemDTO_TypeAndValues()
        {
            // Arrange
            var mockRepo = new Mock <IMovieProvider>();

            mockRepo.Setup(repo => repo.GetAllMovies())
            .ReturnsAsync(ListClasses.GetMockMovies());

            var controller = new MovieController(mockRepo.Object);

            // Act
            var actual = controller.GetAllMovies();
            var kk     = actual.ToList().Count;
            var k      = actual.GetType();

            //Assert
            Assert.IsAssignableFrom <IEnumerable <MovieListItemDTO> >(actual);
            Assert.NotNull(actual);
            Assert.True(actual.ToList().Count != 0);
        }
        public List <Movie> GetAllMovies()
        {
            MovieController movieCtr = new MovieController();

            List <Movie> movieList = movieCtr.GetAllMovies();

            //loop through it to have the schedulers loaded imidiately
            foreach (Movie movie in movieList)
            {
                List <Scheduler> scheduler = movie.Schedulers.ToList();
            }

            return(movieList);


            //SchedulerController schedulerController = new SchedulerController();

            //List<Scheduler> schedulerList = schedulerController.GetAllSchedulers();

            //Reservation reservation = schedulerList.First().Reservations.First();

            //return schedulerList;
        }
Exemplo n.º 9
0
        private void FormMovieList_Load(object sender, EventArgs e)
        {
            List <MovieDTO> dtos = _mc.GetAllMovies();

            lstMovies.DataSourceMember <List <MovieDTO> >("MovieName", "Id", dtos);
        }