Пример #1
0
        public void NotModifyAnythingIfProviderIdDoesntExistInRepository()
        {
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            SetMockDeleteRoutine2(mockUnitOfWork);
            ProviderService providerService = new ProviderService(mockUnitOfWork.Object);

            bool deleted = providerService.MarkProviderAsDeleted(2, It.IsAny <string>());

            mockUnitOfWork.Verify(un => un.ProviderRepository.Update(It.IsAny <Provider>()), Times.Never());
            mockUnitOfWork.Verify(un => un.Save(), Times.Never());
            mockUnitOfWork.Verify(un => un.ProviderRepository.Delete(It.IsAny <int>()), Times.Never());
            Assert.IsFalse(deleted);
        }
Пример #2
0
        public void NotModifyAnythingAndNotFailIfProviderInRepositoryIsAlreadyMarkedAsDeleted()
        {
            Provider alreadyDeletedProvider = new Provider("AntelData", 60, new List <IField>());

            alreadyDeletedProvider.MarkAsInactiveToShowItIsDeleted();
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            SetMockDeleteRoutine3(mockUnitOfWork, alreadyDeletedProvider);
            ProviderService providerService = new ProviderService(mockUnitOfWork.Object);

            bool deleted = providerService.MarkProviderAsDeleted(2, It.IsAny <string>());

            mockUnitOfWork.Verify(un => un.ProviderRepository.Update(It.IsAny <Provider>()), Times.Never());
            mockUnitOfWork.Verify(un => un.Save(), Times.Never());
            mockUnitOfWork.Verify(un => un.ProviderRepository.Delete(It.IsAny <int>()), Times.Never());
            Assert.IsTrue(deleted);
        }
Пример #3
0
        public void BeAbleToMarkAsDeletedAProviderFromRepository()
        {
            User     receivedUser        = new User("Bruno", "*****@*****.**", "#ElBizagra1996", AdminRole.GetInstance());
            Provider toBeDeletedProvider = new Provider("AntelData", 60, new List <IField>());
            var      mockUnitOfWork      = new Mock <IUnitOfWork>();

            SetMockDeleteRoutine1(mockUnitOfWork, toBeDeletedProvider);
            ProviderService providerService = new ProviderService(mockUnitOfWork.Object);

            bool deleted = providerService.MarkProviderAsDeleted(2, receivedUser.Email);

            mockUnitOfWork.Verify(un => un.ProviderRepository.Update(It.IsAny <Provider>()), Times.Exactly(1));
            mockUnitOfWork.Verify(un => un.Save(), Times.Exactly(1));
            mockUnitOfWork.Verify(un => un.ProviderRepository.Delete(It.IsAny <int>()), Times.Never());
            Assert.IsTrue(deleted);
            Assert.IsFalse(toBeDeletedProvider.Active);
        }