コード例 #1
0
ファイル: Delete_Should.cs プロジェクト: papiReta/livescore
        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
ファイル: Delete_Should.cs プロジェクト: papiReta/livescore
        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
ファイル: Delete_Should.cs プロジェクト: papiReta/livescore
        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)));
        }
コード例 #4
0
        public virtual ActionResult DeleteConfirmed(long id)
        {
            _leagueService.Delete(id);

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