public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException() { // Arrange var mockVolumeObjectsRepository = VolumeObjectsMockingSetup.DoMockingSetupForRepository(); mockVolumeObjectsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); 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); // Act/Assert Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST")); }
public void Verify_Deactivate_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.Deactivate("KING-STEPHEN"); // Assert mockVolumeObjectsRepository.Verify(m => m.Deactivate(It.IsAny <IVolumeObject>()), Times.Once); Assert.Equal(true, result); }