コード例 #1
0
        public void GetByIdShouldCallRepositoryGetByIdOnceWithSameId(int fakeId)
        {
            var mockeRepository  = new Mock <IGenericRepository <User> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var genericService   = new SportSqaureGenericServiceMock(mockeRepository.Object, mockedUnitOfWork.Object);

            mockeRepository.Setup(x => x.GetById(fakeId)).Verifiable();
            genericService.GetById(fakeId);
            mockeRepository.Verify(x => x.GetById(It.Is <int>(y => y == fakeId)), Times.Once);
        }
コード例 #2
0
        public void GetByIdShouldCallRepositoryGetByIdOnce()
        {
            var mockeRepository  = new Mock <IGenericRepository <User> >();
            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var genericService   = new SportSqaureGenericServiceMock(mockeRepository.Object, mockedUnitOfWork.Object);

            mockeRepository.Setup(x => x.GetById(1)).Verifiable();
            genericService.GetById(1);
            mockeRepository.Verify(x => x.GetById(1), Times.Once);
        }