public void IndexMethodWithSearchStringReturnsCorrectCollectionOfSports() { //Arrange var sports = new[] { new Sport { Name = "Voetbal" }, new Sport { Name = "Basketbal" }, new Sport { Name = "Hockey" }, new Sport { Name = "Volleybal" } }; var mockManager = new Mock <ISportManager>(); mockManager.Setup(x => x.SportsList()).Returns(sports); var controller = new SportController(mockManager.Object); //Act var result = controller.Index(null, null, "bal", 1); //Assert Assert.IsType(typeof(PagedList <Sport>), result.ViewData.Model); Assert.Equal(3, result.ViewData.Count); }
public void IndexMethodWithSortOrderDescendingReturnsCorrectCollectionOfSportsSortedDescending() { //Arrange var sports = new[] { new Sport { Name = "Voetbal" }, new Sport { Name = "Basketbal" }, new Sport { Name = "Hockey" }, new Sport { Name = "Volleybal" } }; var mockManager = new Mock <ISportManager>(); var controller = new SportController(mockManager.Object); mockManager.Setup(a => a.SportsList()).Returns(sports); //Act var result = controller.Index("name_desc", null, null, 1); var pageList = (PagedList <Sport>)result.ViewData.Model; //Assert Assert.IsType(typeof(PagedList <Sport>), result.ViewData.Model); Assert.Same("Volleybal", pageList[0].Name); }
public void AmountOfPagesOnIndexMethodIsCorrect() { //Arrange var sports = new[] { new Sport { Name = "Voetbal" }, new Sport { Name = "Basketbal" }, new Sport { Name = "Hockey" }, new Sport { Name = "Volleybal" }, new Sport { Name = "Trefbal" }, new Sport { Name = "Tennis" }, new Sport { Name = "Darten" }, new Sport { Name = "Karate" }, new Sport { Name = "Dansen" }, new Sport { Name = "Yoga" }, new Sport { Name = "Badminton" }, new Sport { Name = "Softbal" } }; var mockManager = new Mock <ISportManager>(); var controller = new SportController(mockManager.Object); mockManager.Setup(a => a.SportsList()).Returns(sports); //Act var result = controller.Index(null, null, null, 1); var pageList = (PagedList <Sport>)result.ViewData.Model; //Assert Assert.Equal(2, pageList.PageCount); Assert.Equal(12, pageList.TotalItemCount); }