public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockObjectVolumesRepository = ObjectVolumesMockingSetup.DoMockingSetupForRepository(); mockObjectVolumesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new ObjectVolumesBusinessWorkflow(mockObjectVolumesRepository.Object, new ObjectVolumeMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockObjectVolumesRepository = ObjectVolumesMockingSetup.DoMockingSetupForRepository(); var mockObjectVolumesMapper = new Mock <IObjectVolumeMapper>(); mockObjectVolumesMapper.Setup(m => m.AreEqual(It.IsAny <IObjectVolumeModel>(), It.IsAny <IObjectVolume>())).Returns(() => true); var businessWorkflow = new ObjectVolumesBusinessWorkflow(mockObjectVolumesRepository.Object, mockObjectVolumesMapper.Object); mockObjectVolumesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IObjectVolume>().Object); mockObjectVolumesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockObjectVolumesRepository.Verify(m => m.Remove(It.IsAny <IObjectVolume>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockObjectVolumesRepository = ObjectVolumesMockingSetup.DoMockingSetupForRepository(); var mockObjectVolumesMapper = new Mock<IObjectVolumeMapper>(); mockObjectVolumesMapper.Setup(m => m.AreEqual(It.IsAny<IObjectVolumeModel>(), It.IsAny<IObjectVolume>())).Returns(() => true); var businessWorkflow = new ObjectVolumesBusinessWorkflow(mockObjectVolumesRepository.Object, mockObjectVolumesMapper.Object); mockObjectVolumesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IObjectVolume>().Object); mockObjectVolumesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockObjectVolumesRepository.Verify(m => m.Remove(It.IsAny<IObjectVolume>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockObjectVolumesRepository = ObjectVolumesMockingSetup.DoMockingSetupForRepository(); mockObjectVolumesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new ObjectVolumesBusinessWorkflow(mockObjectVolumesRepository.Object, new ObjectVolumeMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }