Example #1
0
        public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
        {
            // Arrange
            var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();

            mockResourceTypesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
            // Act
            var result = businessWorkflow.Remove("DOESNT-EXIST");

            // Assert
            Assert.Equal(true, result);
        }
Example #2
0
        public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
            var mockResourceTypesMapper     = new Mock <IResourceTypeMapper>();

            mockResourceTypesMapper.Setup(m => m.AreEqual(It.IsAny <IResourceTypeModel>(), It.IsAny <IResourceType>())).Returns(() => true);
            var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, mockResourceTypesMapper.Object);

            mockResourceTypesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IResourceType>().Object);
            mockResourceTypesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
            // Act
            var result = businessWorkflow.Remove("KING-STEPHEN");

            // Assert
            mockResourceTypesRepository.Verify(m => m.Remove(It.IsAny <IResourceType>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
     var mockResourceTypesMapper = new Mock<IResourceTypeMapper>();
     mockResourceTypesMapper.Setup(m => m.AreEqual(It.IsAny<IResourceTypeModel>(), It.IsAny<IResourceType>())).Returns(() => true);
     var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, mockResourceTypesMapper.Object);
     mockResourceTypesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IResourceType>().Object);
     mockResourceTypesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Remove("KING-STEPHEN");
     // Assert
     mockResourceTypesRepository.Verify(m => m.Remove(It.IsAny<IResourceType>()), Times.Once);
     Assert.Equal(true, result);
 }
 public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
 {
     // Arrange
     var mockResourceTypesRepository = ResourceTypesMockingSetup.DoMockingSetupForRepository();
     mockResourceTypesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null);
     var businessWorkflow = new ResourceTypesBusinessWorkflow(mockResourceTypesRepository.Object, new ResourceTypeMapper());
     // Act
     var result = businessWorkflow.Remove("DOESNT-EXIST");
     // Assert
     Assert.Equal(true, result);
 }