public void SetSelectedSeasonYear_WhenSeasonYearArgIsNull_ShouldReturnBadRequest() { // Arrange var seasonStandingsIndexViewModel = A.Fake <ISeasonStandingsIndexViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); var seasonStandingsRepository = A.Fake <ISeasonStandingsRepository>(); var testController = new SeasonStandingsController(seasonStandingsIndexViewModel, seasonRepository, seasonStandingsRepository); int?seasonYear = null; // Act var result = testController.SetSelectedSeasonYear(seasonYear); // Assert result.ShouldBeOfType <BadRequestResult>(); }
public void SetSelectedSeasonYear_WhenSeasonYearArgIsNotNull_ShouldSetSelectedSeasonYearAndRedirectToIndexView() { // Arrange var seasonStandingsIndexViewModel = A.Fake <ISeasonStandingsIndexViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); var seasonStandingsRepository = A.Fake <ISeasonStandingsRepository>(); var testController = new SeasonStandingsController(seasonStandingsIndexViewModel, seasonRepository, seasonStandingsRepository); int?seasonYear = 1920; // Act var result = testController.SetSelectedSeasonYear(seasonYear); // Assert SeasonStandingsController.SelectedSeasonYear.ShouldBe(seasonYear.Value); result.ShouldBeOfType <RedirectToActionResult>(); ((RedirectToActionResult)result).ActionName.ShouldBe <string>(nameof(testController.Index)); }