Example #1
0
        public void CallUnitOfWorkCommitMethodOnce()
        {
            var            leagueMock     = new Mock <League>();
            var            repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var            unitOfWorkMock = new Mock <IUnitOfWork>();
            ILeagueService leagueService  = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            leagueService.DeleteLeague(leagueMock.Object);

            unitOfWorkMock.Verify(x => x.Commit(), Times.Once);
        }
Example #2
0
        public void CallRepositoryMethodOnce_WhenDataIsValid()
        {
            var            leagueMock     = new Mock <League>();
            var            repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var            unitOfWorkMock = new Mock <IUnitOfWork>();
            ILeagueService leagueService  = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            leagueService.DeleteLeague(leagueMock.Object);

            repositoryMock.Verify(x => x.Delete(It.IsAny <League>()), Times.Once);
        }
Example #3
0
        public IHttpActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            LeagueService service = CreateLeagueService();

            if (service.DeleteLeague(id.Value))
            {
                return(Ok());
            }

            return(InternalServerError());
        }