public void All_ShouldReturnCorrectDataWithValidInput()
        {
            //Arrange
            var controller = new RoutesController(this.routeService.Object, this.townService.Object, this.fixture.UserManagerMockInstance.Object, null, null);

            this.routeService.Setup(t => t.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(this.GetRoutes());

            this.routeService.Setup(t => t.TotalRoutes(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <string>()))
            .Returns(TotalRoutes);

            this.townService.Setup(t => t.GetTownsListItems())
            .Returns(this.GetTowns());

            this.townService.Setup(t => t.GetTownsWithStations())
            .Returns(this.GetTownsStations());

            //Act
            var result = controller.All(StartTown, EndTown, Date, MinPageSize);

            //Assert
            result.Should().BeOfType <ViewResult>();
            var model = result.As <ViewResult>().Model.As <AllRoutes>();

            model.Routes.Should().HaveCount(TotalRoutes);
            model.Pagination.CurrentPage.Should().Be(MinPageSize);
            model.Pagination.NextPage.Should().Be(MaxPageSize);
            model.Pagination.PreviousPage.Should().Be(MinPageSize);
            model.Pagination.TotalElements.Should().Be(TotalRoutes);
        }
        public void All_WithPageLessOrEqualToZeroShouldRedirectToAllCompanyRoutes(int page)
        {
            //Arrange
            var controller = new RoutesController(null, null, null, null, null);

            //Act
            var result = controller.All(StartTown, EndTown, Date, page);

            //Assert
            result.Should().BeOfType <RedirectToActionResult>();
            var model = result.As <RedirectToActionResult>();

            model.ActionName.Should().Be(WebConstants.Action.CompanyAllRoutes);
            model.RouteValues.Keys.Should().Contain(RouteValueKeyPage);
            model.RouteValues.Values.Should().Contain(MinPageSize);
            model.RouteValues.Keys.Should().Contain(RouteValueStartTownKey);
            model.RouteValues.Values.Should().Contain(StartTown);
            model.RouteValues.Keys.Should().Contain(RouteValueEndTownKey);
            model.RouteValues.Values.Should().Contain(EndTown);
            model.RouteValues.Keys.Should().Contain(RouteValueDateKey);
            model.RouteValues.Values.Should().Contain(Date.ToYearMonthDayFormat());
        }
        public void All_PageGreaterThanTotalPagesShouldRedirectToAllCompanyRoutes()
        {
            const int InvalidPageSize = 10;

            //Arrange
            var controller = new RoutesController(this.routeService.Object, this.townService.Object, this.fixture.UserManagerMockInstance.Object, null, null);

            this.routeService.Setup(t => t.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()))
            .Returns(this.GetRoutes());

            this.routeService.Setup(t => t.TotalRoutes(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <string>()))
            .Returns(TotalRoutes);

            this.townService.Setup(t => t.GetTownsListItems())
            .Returns(this.GetTowns());

            this.townService.Setup(t => t.GetTownsWithStations())
            .Returns(this.GetTownsStations());

            //Act
            var result = controller.All(StartTown, EndTown, Date, InvalidPageSize);

            //Assert
            result.Should().BeOfType <RedirectToActionResult>();
            var model = result.As <RedirectToActionResult>();

            model.ActionName.Should().Be(WebConstants.Action.CompanyAllRoutes);
            model.RouteValues.Keys.Should().Contain(RouteValueKeyPage);
            model.RouteValues.Values.Should().Contain(MaxPageSize);
            model.RouteValues.Keys.Should().Contain(RouteValueStartTownKey);
            model.RouteValues.Values.Should().Contain(StartTown);
            model.RouteValues.Keys.Should().Contain(RouteValueEndTownKey);
            model.RouteValues.Values.Should().Contain(EndTown);
            model.RouteValues.Keys.Should().Contain(RouteValueDateKey);
            model.RouteValues.Values.Should().Contain(Date.ToYearMonthDayFormat());
        }