Exemple #1
0
        public async Task Delete_WhenIdIsNotNullAndTeamSeasonIsFound_ShouldReturnTeamSeasonDeleteView()
        {
            // Arrange
            var teamSeasonsIndexViewModel   = A.Fake <ITeamSeasonsIndexViewModel>();
            var teamSeasonsDetailsViewModel = A.Fake <ITeamSeasonsDetailsViewModel>();

            var        teamSeasonRepository = A.Fake <ITeamSeasonRepository>();
            TeamSeason?teamSeason           = new TeamSeason();

            A.CallTo(() => teamSeasonRepository.GetTeamSeasonAsync(A <int> .Ignored)).Returns(teamSeason);

            var sharedRepository = A.Fake <ISharedRepository>();
            var testController   = new TeamSeasonsAdminController(teamSeasonsIndexViewModel, teamSeasonsDetailsViewModel,
                                                                  teamSeasonRepository, sharedRepository);

            int?id = 1;

            // Act
            var result = await testController.Delete(id);

            // Assert
            A.CallTo(() => teamSeasonRepository.GetTeamSeasonAsync(id.Value)).MustHaveHappenedOnceExactly();
            result.ShouldBeOfType <ViewResult>();
            ((ViewResult)result).Model.ShouldBe(teamSeason);
        }
Exemple #2
0
        public async Task Delete_WhenIdIsNull_ShouldReturnNotFound()
        {
            // Arrange
            var teamSeasonsIndexViewModel   = A.Fake <ITeamSeasonsIndexViewModel>();
            var teamSeasonsDetailsViewModel = A.Fake <ITeamSeasonsDetailsViewModel>();
            var teamSeasonRepository        = A.Fake <ITeamSeasonRepository>();
            var sharedRepository            = A.Fake <ISharedRepository>();
            var testController = new TeamSeasonsAdminController(teamSeasonsIndexViewModel, teamSeasonsDetailsViewModel,
                                                                teamSeasonRepository, sharedRepository);

            int?id = null;

            // Act
            var result = await testController.Delete(id);

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