Exemplo n.º 1
0
        public void Get_Returns_Count_Of_TvShows()
        {
            // arrange
            var expectedTvShows = new List <TvShow>()
            {
                new TvShow(1, "Test Show Title", "test.img", "Test Season", "Test Viewer Discretion"),
                new TvShow(2, "Test Show Title", "test.img", "Test Season", "Test Viewer Discretion")
            };

            //albumList
            tvShowMockRepo.GetAll().Returns(expectedTvShows);

            // act
            var result         = testController.Get();
            var countOfTvShows = result.Count();

            // assert
            Assert.Equal(2, countOfTvShows);
        }
Exemplo n.º 2
0
        public void TestApiWithPaginationWhenMoreThanTenTvShowsPageOneEqualsNoPageParameter()
        {
            var tvshows  = GetMockedListOfTvShows(25);
            var mockRepo = new Mock <ITvShowRepository>();

            mockRepo.Setup(repo => repo.Get()).Returns(tvshows);

            var controller = new TvShowController(mockRepo.Object);

            var resultsNoPageParameter = Assert.IsType <OkObjectResult>(controller.Get().Result);

            Assert.Equal(200, resultsNoPageParameter.StatusCode);

            var resultsPageOne = Assert.IsType <OkObjectResult>(controller.Get(1).Result);

            Assert.Equal(200, resultsPageOne.StatusCode);

            var listNoPageParameter = new List <TvShow>((IEnumerable <TvShow>)resultsNoPageParameter.Value);
            var listPageOne         = new List <TvShow>((IEnumerable <TvShow>)resultsPageOne.Value);

            Assert.Equal(listNoPageParameter, listPageOne);
        }
Exemplo n.º 3
0
        public void TestApiWithPaginationOnPageWithNoElementsAndEmptyListReturn()
        {
            var tvshows  = GetMockedListOfTvShows(25);
            var mockRepo = new Mock <ITvShowRepository>();

            mockRepo.Setup(repo => repo.Get()).Returns(tvshows);

            var controller = new TvShowController(mockRepo.Object);

            var results = Assert.IsType <OkObjectResult>(controller.Get(4).Result);

            Assert.Equal(200, results.StatusCode);

            var list = new List <TvShow>((IEnumerable <TvShow>)results.Value);

            Assert.Empty(list);
        }
Exemplo n.º 4
0
        public void TestApiNoPagination()
        {
            var tvshows = new List <TvShow>()
            {
                new TvShow()
                {
                    Id   = 1,
                    Name = "Tv Show 1",
                    Cast = new List <CastMember>()
                    {
                        new CastMember()
                        {
                            Id = 1, Name = "Actor 1", Birthday = DateTime.Now.AddYears(-30)
                        }
                    }
                },
                new TvShow()
                {
                    Id = 2, Name = "Tv Show 2"
                }
            };

            var mockRepo = new Mock <ITvShowRepository>();

            mockRepo.Setup(repo => repo.Get()).Returns(tvshows);

            var controller = new TvShowController(mockRepo.Object);

            var results = Assert.IsType <OkObjectResult>(controller.Get().Result);

            Assert.Equal(200, results.StatusCode);

            var list = new List <TvShow>((IEnumerable <TvShow>)results.Value);

            Assert.Equal(2, list.Count);
        }