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); }
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); }
public IHttpActionResult Delete(int?id) { if (id == null) { return(BadRequest()); } LeagueService service = CreateLeagueService(); if (service.DeleteLeague(id.Value)) { return(Ok()); } return(InternalServerError()); }