Example #1
0
        public void AddSholdCallUnitOfWorkComitOnce()
        {
            var mockeRepository  = new Mock <IGenericEfRepository <Category> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var genericService   = new NoleggioGenericServiceMock(mockeRepository.Object, mockedUnitOfWork.Object);

            mockedUnitOfWork.Setup(x => x.Commit()).Verifiable();
            genericService.Add(new Category());
            mockedUnitOfWork.Verify(x => x.Commit(), Times.Once);
        }
Example #2
0
        public void AddSholdCallRepositoryAddWithSameUser()
        {
            var mockeRepository  = new Mock <IGenericEfRepository <Category> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var fakecategory     = new Category();
            var genericService   = new NoleggioGenericServiceMock(mockeRepository.Object, mockedUnitOfWork.Object);

            mockeRepository.Setup(x => x.Add(fakecategory)).Verifiable();
            genericService.Add(fakecategory);
            mockeRepository.Verify(x => x.Add(It.Is <Category>(y => y == fakecategory)), Times.Once);
        }