Пример #1
0
        public void SetSelectedSeasonYear_WhenSeasonYearIsNotNull_ShouldSetSelectedSeasonYearAndRedirectToIndex()
        {
            // Arrange
            var teamSeasonsIndexViewModel    = A.Fake <ITeamSeasonsIndexViewModel>();
            var teamSeasonsDetailsViewModel  = A.Fake <ITeamSeasonsDetailsViewModel>();
            var seasonRepository             = A.Fake <ISeasonRepository>();
            var teamSeasonRepository         = A.Fake <ITeamSeasonRepository>();
            var teamSeasonScheduleRepository = A.Fake <ITeamSeasonScheduleRepository>();
            var sharedRepository             = A.Fake <ISharedRepository>();
            var weeklyUpdateService          = A.Fake <IWeeklyUpdateService>();

            var testController = new TeamSeasonsController(teamSeasonsIndexViewModel, teamSeasonsDetailsViewModel,
                                                           seasonRepository, teamSeasonRepository, teamSeasonScheduleRepository, sharedRepository,
                                                           weeklyUpdateService);

            int?seasonYear = 1920;

            // Act
            var result = testController.SetSelectedSeasonYear(seasonYear);

            // Assert
            TeamSeasonsController.SelectedSeasonYear.ShouldBe(seasonYear.Value);
            result.ShouldBeOfType <RedirectToActionResult>();
            ((RedirectToActionResult)result).ActionName.ShouldBe <string>(nameof(testController.Index));
        }
Пример #2
0
        public void SetSelectedSeasonYear_WhenSeasonYearIsNull_ShouldReturnBadRequest()
        {
            // Arrange
            var teamSeasonsIndexViewModel    = A.Fake <ITeamSeasonsIndexViewModel>();
            var teamSeasonsDetailsViewModel  = A.Fake <ITeamSeasonsDetailsViewModel>();
            var seasonRepository             = A.Fake <ISeasonRepository>();
            var teamSeasonRepository         = A.Fake <ITeamSeasonRepository>();
            var teamSeasonScheduleRepository = A.Fake <ITeamSeasonScheduleRepository>();
            var sharedRepository             = A.Fake <ISharedRepository>();
            var weeklyUpdateService          = A.Fake <IWeeklyUpdateService>();

            var testController = new TeamSeasonsController(teamSeasonsIndexViewModel, teamSeasonsDetailsViewModel,
                                                           seasonRepository, teamSeasonRepository, teamSeasonScheduleRepository, sharedRepository,
                                                           weeklyUpdateService);

            int?seasonYear = null;

            // Act
            var result = testController.SetSelectedSeasonYear(seasonYear);

            // Assert
            result.ShouldBeOfType <BadRequestResult>();
        }