public async Task Delete_WhenIdIsNotNullAndSeasonFound_ShouldReturnSeasonDeleteView() { // 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.Delete(id); // Assert A.CallTo(() => seasonRepository.GetSeasonAsync(id.Value)).MustHaveHappenedOnceExactly(); result.ShouldBeOfType <ViewResult>(); ((ViewResult)result).Model.ShouldBe(season); }
public async Task Delete_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.Delete(id); // Assert result.ShouldBeOfType <NotFoundResult>(); }