public void ThrowArgumentNullException_WhenPlayerIsNull() { var mockedRepository = new Mock <IWhoScoredRepository <FootballPlayer> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); IFootballPlayerService footballPlayerService = new FootballPlayerService(mockedRepository.Object, mockedUnitOfWork.Object); var exception = Assert.Throws <ArgumentNullException>(() => footballPlayerService.UpdateFootballPlayer(null)); StringAssert.IsMatch("footballPlayer", exception.ParamName); }
public void CallCommitMethodOnce_WhenPlayerIsValid() { var mockedRepository = new Mock <IWhoScoredRepository <FootballPlayer> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPlayer = new Mock <FootballPlayer>(); IFootballPlayerService footballPlayerService = new FootballPlayerService(mockedRepository.Object, mockedUnitOfWork.Object); footballPlayerService.UpdateFootballPlayer(mockedPlayer.Object); mockedUnitOfWork.Verify(x => x.Commit(), Times.Once); }