Example #1
0
        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.DeleteFootballPlayer(null));

            StringAssert.IsMatch("footballPlayer", exception.ParamName);
        }
Example #2
0
        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.DeleteFootballPlayer(mockedPlayer.Object);

            mockedUnitOfWork.Verify(x => x.Commit(), Times.Once);
        }