public void Location_Can_Send_Pagination()
        {
            // Arrange
            Mock <ILogger <LocationsController> > mockLogger             = new Mock <ILogger <LocationsController> >();
            Mock <ILocationRepository>            mockLocationRepository = new Mock <ILocationRepository>();

            mockLocationRepository.Setup(m => m.GetLocations).Returns((new Location[] {
                new Location {
                    LocationId = 1, ParentId = 0, Description = "L1"
                },
                new Location {
                    LocationId = 2, ParentId = 1, Description = "L2"
                },
                new Location {
                    LocationId = 3, ParentId = 1, Description = "L3"
                },
                new Location {
                    LocationId = 4, ParentId = 1, Description = "L4"
                },
                new Location {
                    LocationId = 5, ParentId = 1, Description = "L5"
                }
            }).AsQueryable <Location>());

            LocationsController controller = new LocationsController(mockLogger.Object, mockLocationRepository.Object);

            controller.PageSize = 3;

            // Act
            LocationsListViewModel result = controller.List(2).ViewData.Model as LocationsListViewModel;

            // Assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(2, pageInfo.CurrentPage);
            Assert.AreEqual(3, pageInfo.ItemsPerPage);
            Assert.AreEqual(5, pageInfo.TotalItems);
            Assert.AreEqual(2, pageInfo.TotalPages);
        }
        public void Location_Can_Paginate()
        {
            // Arrange
            Mock <ILogger <LocationsController> > mockLogger             = new Mock <ILogger <LocationsController> >();
            Mock <ILocationRepository>            mockLocationRepository = new Mock <ILocationRepository>();

            mockLocationRepository.Setup(m => m.GetLocations).Returns((new Location[] {
                new Location {
                    LocationId = 1, ParentId = 0, Description = "L1"
                },
                new Location {
                    LocationId = 2, ParentId = 1, Description = "L2"
                },
                new Location {
                    LocationId = 3, ParentId = 1, Description = "L3"
                },
                new Location {
                    LocationId = 4, ParentId = 1, Description = "L4"
                },
                new Location {
                    LocationId = 5, ParentId = 1, Description = "L5"
                }
            }).AsQueryable <Location>());

            LocationsController controller = new LocationsController(mockLogger.Object, mockLocationRepository.Object);

            controller.PageSize = 3;

            // Act
            LocationsListViewModel result = controller.List(2).ViewData.Model as LocationsListViewModel;

            // Assert
            Location[] LocationArray = result.Locations.ToArray();
            Assert.IsTrue(LocationArray.Length == 2);
            Assert.AreEqual("L4", LocationArray[0].Description);
            Assert.AreEqual("L5", LocationArray[1].Description);
        }