コード例 #1
0
ファイル: Update_Should.cs プロジェクト: ihristova11/GetHired
        public void ReturnFalse_WhenNullArgumentIsPassed()
        {
            //Arrange
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedMapper     = new Mock <IMapper>();
            var jobOfferService  = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object);

            //Act & Assert
            Assert.IsFalse(jobOfferService.Update(null));
        }
コード例 #2
0
ファイル: Update_Should.cs プロジェクト: ihristova11/GetHired
        public void ReturnFalse_WhenExceptionOccured()
        {
            //Arrange
            var mockedUnitOfWork    = new Mock <IUnitOfWork>();
            var mockedMapper        = new Mock <IMapper>();
            var jobOfferService     = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object);
            var mockedJobOfferModel = new Mock <JobOfferModel>();

            //Act
            mockedUnitOfWork.Setup(x => x.JobOfferRepository).Throws(new Exception());

            //Assert
            Assert.IsFalse(jobOfferService.Update(mockedJobOfferModel.Object));
        }
コード例 #3
0
ファイル: Update_Should.cs プロジェクト: ihristova11/GetHired
        public void CallMapperMapMethod_WhenInvokedWithValidArgs()
        {
            //Arrange
            var mockedUnitOfWork         = new Mock <IUnitOfWork>();
            var mockedMapper             = new Mock <IMapper>();
            var jobOfferService          = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object);
            var mockedJobOfferRepository = new Mock <IJobOfferRepository>();
            var mockedJobOffer           = new Mock <JobOffer>();
            var mockedJobOfferModel      = new Mock <JobOfferModel>();

            //Act
            mockedMapper.Setup(x => x.Map <JobOffer>(mockedJobOfferModel.Object)).Returns(mockedJobOffer.Object);
            jobOfferService.Update(mockedJobOfferModel.Object);

            //Assert
            mockedMapper.Verify(x => x.Map <JobOffer>(mockedJobOfferModel.Object), Times.Once);
        }
コード例 #4
0
ファイル: Update_Should.cs プロジェクト: ihristova11/GetHired
        public void ExecuteMethodAndReturnTrue_WhenInvokedWithValidArgs()
        {
            //Arrange
            var mockedUnitOfWork         = new Mock <IUnitOfWork>();
            var mockedMapper             = new Mock <IMapper>();
            var jobOfferService          = new JobOfferService(mockedUnitOfWork.Object, mockedMapper.Object);
            var mockedJobOfferRepository = new Mock <IJobOfferRepository>();
            var mockedJobOffer           = new Mock <JobOffer>();
            var mockedJobOfferModel      = new Mock <JobOfferModel>();

            //Act
            mockedMapper.Setup(x => x.Map <JobOffer>(mockedJobOfferModel.Object)).Returns(mockedJobOffer.Object);
            mockedUnitOfWork.Setup(x => x.JobOfferRepository).Returns(mockedJobOfferRepository.Object);
            mockedJobOfferRepository.Setup(x => x.Update(mockedJobOffer.Object));
            mockedUnitOfWork.Setup(x => x.SaveChanges());

            //Assert
            Assert.IsTrue(jobOfferService.Update(mockedJobOfferModel.Object));
        }