示例#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.UpdateFootballPlayer(null));

            StringAssert.IsMatch("footballPlayer", exception.ParamName);
        }
示例#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.UpdateFootballPlayer(mockedPlayer.Object);

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