public void IndexMethodWithSearchStringReturnsCorrectPagedListOfSportEventViewModels()
        {
            //Arrange
            var sportEvents = new[]
            {
                new SportEvent {
                    Name = "Voetbal"
                },
                new SportEvent {
                    Name = "Basketbal"
                },
                new SportEvent {
                    Name = "Hockey"
                },
                new SportEvent {
                    Name = "Volleybal"
                }
            };
            var mockSportManager      = new Mock <ISportManager>();
            var mockSportEventManager = new Mock <ISportEventManager>();

            mockSportEventManager.Setup(x => x.ViewAllSportEvents()).Returns(sportEvents);
            var controller = new SportEventController(mockSportEventManager.Object, mockSportManager.Object);

            //Act
            var result = controller.Index(null, null, "bal", 1) as ViewResult;
            var model  = (IEnumerable <SportEventViewModel>)result?.Model;
            var countModelsInViewModels = model.Count();

            //Assert
            Assert.IsType(typeof(PagedList <SportEventViewModel>), result.ViewData.Model);
            Assert.Equal(3, countModelsInViewModels);
        }
        public void IndexMethodWithSortOrderDescendingReturnsCorrectCollectionOfSportEventsSortedDescending()
        {
            //Arrange
            var sportEvents = new[]
            {
                new SportEvent {
                    Name = "Voetbal"
                },
                new SportEvent {
                    Name = "Basketbal"
                },
                new SportEvent {
                    Name = "Hockey"
                },
                new SportEvent {
                    Name = "Volleybal"
                }
            };
            var mockSportManager      = new Mock <ISportManager>();
            var mockSportEventManager = new Mock <ISportEventManager>();
            var controller            = new SportEventController(mockSportEventManager.Object, mockSportManager.Object);


            mockSportEventManager.Setup(a => a.ViewAllSportEvents()).Returns(sportEvents);

            //Act
            var result   = controller.Index("name_desc", null, null, 1) as ViewResult;
            var pageList = (PagedList <SportEventViewModel>)result.ViewData.Model;

            //Assert
            Assert.IsType(typeof(PagedList <SportEventViewModel>), result.ViewData.Model);
            Assert.Same("Volleybal", pageList[0].Name);
        }
        public void AmountOfPagesOnIndexMethodIsCorrect()
        {
            //Arrange
            var sportEvents = new[]
            {
                new SportEvent {
                    Name = "Voetbal"
                },
                new SportEvent {
                    Name = "Basketbal"
                },
                new SportEvent {
                    Name = "Hockey"
                },
                new SportEvent {
                    Name = "Volleybal"
                },
                new SportEvent {
                    Name = "Trefbal"
                },
                new SportEvent {
                    Name = "Tennis"
                },
                new SportEvent {
                    Name = "Darten"
                },
                new SportEvent {
                    Name = "Karate"
                },
                new SportEvent {
                    Name = "Dansen"
                },
                new SportEvent {
                    Name = "Yoga"
                },
                new SportEvent {
                    Name = "Badminton"
                },
                new SportEvent {
                    Name = "Softbal"
                }
            };

            var mockSportManager      = new Mock <ISportManager>();
            var mockSportEventManager = new Mock <ISportEventManager>();
            var controller            = new SportEventController(mockSportEventManager.Object, mockSportManager.Object);

            mockSportEventManager.Setup(a => a.ViewAllSportEvents()).Returns(sportEvents);

            //Act
            var result   = controller.Index(null, null, null, 1) as ViewResult;
            var pageList = (PagedList <SportEventViewModel>)result.ViewData.Model;

            //Assert
            Assert.Equal(2, pageList.PageCount);
            Assert.Equal(12, pageList.TotalItemCount);
        }