public async Task Details_WhenIdIsNotNullAndTeamSeasonIsNotFound_ShouldReturnNotFound() { // Arrange var teamSeasonsIndexViewModel = A.Fake <ITeamSeasonsIndexViewModel>(); var teamSeasonsDetailsViewModel = A.Fake <ITeamSeasonsDetailsViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); var teamSeasonRepository = A.Fake <ITeamSeasonRepository>(); TeamSeason?teamSeason = null; A.CallTo(() => teamSeasonRepository.GetTeamSeasonAsync(A <int> .Ignored)).Returns(teamSeason); 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?id = 1; // Act var result = await testController.Details(id); // Assert A.CallTo(() => teamSeasonRepository.GetTeamSeasonAsync(id.Value)).MustHaveHappenedOnceExactly(); result.ShouldBeOfType <NotFoundResult>(); }
public async Task Details_WhenIdIsNull_ShouldReturnNotFound() { // 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?id = null; // Act var result = await testController.Details(id); // Assert result.ShouldBeOfType <NotFoundResult>(); }
public async Task Details_WhenIdIsNotNullAndTeamSeasonIsFound_ShouldReturnNotFound() { // Arrange var teamSeasonsIndexViewModel = A.Fake <ITeamSeasonsIndexViewModel>(); var teamSeasonsDetailsViewModel = A.Fake <ITeamSeasonsDetailsViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); var teamSeasonRepository = A.Fake <ITeamSeasonRepository>(); string teamName = "Team"; int seasonYear = 1920; TeamSeason?teamSeason = new TeamSeason { TeamName = teamName, SeasonYear = seasonYear }; A.CallTo(() => teamSeasonRepository.GetTeamSeasonAsync(A <int> .Ignored)).Returns(teamSeason); var teamSeasonScheduleRepository = A.Fake <ITeamSeasonScheduleRepository>(); var teamSeasonScheduleProfile = new List <TeamSeasonOpponentProfile>(); A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleProfileAsync(A <string> .Ignored, A <int> .Ignored)).Returns(teamSeasonScheduleProfile); var teamSeasonScheduleTotals = new TeamSeasonScheduleTotals(); A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleTotalsAsync(A <string> .Ignored, A <int> .Ignored)).Returns(teamSeasonScheduleTotals); var teamSeasonScheduleAverages = new TeamSeasonScheduleAverages(); A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleAveragesAsync(A <string> .Ignored, A <int> .Ignored)).Returns(teamSeasonScheduleAverages); var sharedRepository = A.Fake <ISharedRepository>(); var weeklyUpdateService = A.Fake <IWeeklyUpdateService>(); var testController = new TeamSeasonsController(teamSeasonsIndexViewModel, teamSeasonsDetailsViewModel, seasonRepository, teamSeasonRepository, teamSeasonScheduleRepository, sharedRepository, weeklyUpdateService); int?id = 1; // Act var result = await testController.Details(id); // Assert teamSeasonsDetailsViewModel.TeamSeason = teamSeason; A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleProfileAsync(teamName, seasonYear)) .MustHaveHappenedOnceExactly(); teamSeasonsDetailsViewModel.TeamSeasonScheduleProfile.ShouldBe(teamSeasonScheduleProfile); A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleTotalsAsync(teamName, seasonYear)) .MustHaveHappenedOnceExactly(); teamSeasonsDetailsViewModel.TeamSeasonScheduleTotals.ShouldBe(teamSeasonScheduleTotals); A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleAveragesAsync(teamName, seasonYear)).MustHaveHappenedOnceExactly(); teamSeasonsDetailsViewModel.TeamSeasonScheduleAverages.ShouldBe(teamSeasonScheduleAverages); result.ShouldBeOfType <ViewResult>(); ((ViewResult)result).Model.ShouldBe(teamSeasonsDetailsViewModel); }