Пример #1
0
        public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
        {
            // Arrange
            var mockVolumeObjectsRepository = VolumeObjectsMockingSetup.DoMockingSetupForRepository();

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

            // Assert
            Assert.Equal(true, result);
        }
Пример #2
0
        public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockVolumeObjectsRepository = VolumeObjectsMockingSetup.DoMockingSetupForRepository();
            var mockVolumeObjectsMapper     = new Mock <IVolumeObjectMapper>();

            mockVolumeObjectsMapper.Setup(m => m.AreEqual(It.IsAny <IVolumeObjectModel>(), It.IsAny <IVolumeObject>())).Returns(() => true);
            var businessWorkflow = new VolumeObjectsBusinessWorkflow(mockVolumeObjectsRepository.Object, mockVolumeObjectsMapper.Object);

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

            // Assert
            mockVolumeObjectsRepository.Verify(m => m.Remove(It.IsAny <IVolumeObject>()), Times.Once);
            Assert.Equal(true, result);
        }