public async Task Details_WhenIdIsNotNullAndSeasonFound_ShouldReturnSeasonDetailsView() { // Arrange var seasonsIndexViewModel = A.Fake <ISeasonsIndexViewModel>(); var seasonsDetailsViewModel = A.Fake <ISeasonsDetailsViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); Season?season = new Season(); A.CallTo(() => seasonRepository.GetSeasonAsync(A <int> .Ignored)).Returns(season); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new SeasonsController(seasonsIndexViewModel, seasonsDetailsViewModel, seasonRepository, sharedRepository); int?id = 0; // Act var result = await testController.Details(id); // Assert seasonsDetailsViewModel.Title.ShouldBe <string>("Season"); A.CallTo(() => seasonRepository.GetSeasonAsync(id.Value)).MustHaveHappenedOnceExactly(); seasonsDetailsViewModel.Season.ShouldBe(season); result.ShouldBeOfType <ViewResult>(); ((ViewResult)result).Model.ShouldBe(seasonsDetailsViewModel); }
public async Task Details_WhenIdIsNull_ShouldReturnNotFound() { // Arrange var seasonsIndexViewModel = A.Fake <ISeasonsIndexViewModel>(); var seasonsDetailsViewModel = A.Fake <ISeasonsDetailsViewModel>(); var seasonRepository = A.Fake <ISeasonRepository>(); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new SeasonsController(seasonsIndexViewModel, seasonsDetailsViewModel, seasonRepository, sharedRepository); int?id = null; // Act var result = await testController.Details(id); // Assert result.ShouldBeOfType <NotFoundResult>(); }