示例#1
0
        public void ReturnFalse_WhenPassedLeagueNameDoesNotTargetExistingLeague()
        {
            // arrange
            var leaguesRepo   = new Mock <IEfRepository <League> >();
            var countriesRepo = new Mock <IEfRepository <Country> >();

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>().AsQueryable());
            var leagueService = new LeagueService(leaguesRepo.Object, countriesRepo.Object);

            // act
            var returnValue = leagueService.Delete("someName");

            // assert
            Assert.IsFalse(returnValue);
        }
示例#2
0
        public void ReturnTrue_WhenLeagueIsDeletedSuccessfully()
        {
            // arrange
            var leaguesRepo   = new Mock <IEfRepository <League> >();
            var countriesRepo = new Mock <IEfRepository <Country> >();

            var league = new League()
            {
                Name = "someName"
            };

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>()
            {
                league
            }.AsQueryable());
            var leagueService = new LeagueService(leaguesRepo.Object, countriesRepo.Object);

            // act
            var returnValue = leagueService.Delete("someName");

            // assert
            Assert.IsTrue(returnValue);
        }
示例#3
0
        public void CallLeagueReposDeleteMethodWithCorrectLeagueObject_WhenLeagueNameTargetsExistingLeague()
        {
            // arrange
            var leaguesRepo   = new Mock <IEfRepository <League> >();
            var countriesRepo = new Mock <IEfRepository <Country> >();

            var league = new League()
            {
                Name = "someName"
            };

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>()
            {
                league
            }.AsQueryable());
            var leagueService = new LeagueService(leaguesRepo.Object, countriesRepo.Object);

            // act
            var returnValue = leagueService.Delete("someName");

            // assert
            leaguesRepo.Verify(lr => lr.Delete(It.Is <League>(l => l == league)));
        }
        public virtual ActionResult DeleteConfirmed(long id)
        {
            _leagueService.Delete(id);

            return(RedirectToAction(MVC.Admin.Leagues.Index()));
        }