public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockLocationVolumesRepository = LocationVolumesMockingSetup.DoMockingSetupForRepository(); mockLocationVolumesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new LocationVolumesBusinessWorkflow(mockLocationVolumesRepository.Object, new LocationVolumeMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockLocationVolumesRepository = LocationVolumesMockingSetup.DoMockingSetupForRepository(); var mockLocationVolumesMapper = new Mock <ILocationVolumeMapper>(); mockLocationVolumesMapper.Setup(m => m.AreEqual(It.IsAny <ILocationVolumeModel>(), It.IsAny <ILocationVolume>())).Returns(() => true); var businessWorkflow = new LocationVolumesBusinessWorkflow(mockLocationVolumesRepository.Object, mockLocationVolumesMapper.Object); mockLocationVolumesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <ILocationVolume>().Object); mockLocationVolumesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockLocationVolumesRepository.Verify(m => m.Remove(It.IsAny <ILocationVolume>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockLocationVolumesRepository = LocationVolumesMockingSetup.DoMockingSetupForRepository(); var mockLocationVolumesMapper = new Mock<ILocationVolumeMapper>(); mockLocationVolumesMapper.Setup(m => m.AreEqual(It.IsAny<ILocationVolumeModel>(), It.IsAny<ILocationVolume>())).Returns(() => true); var businessWorkflow = new LocationVolumesBusinessWorkflow(mockLocationVolumesRepository.Object, mockLocationVolumesMapper.Object); mockLocationVolumesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<ILocationVolume>().Object); mockLocationVolumesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockLocationVolumesRepository.Verify(m => m.Remove(It.IsAny<ILocationVolume>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockLocationVolumesRepository = LocationVolumesMockingSetup.DoMockingSetupForRepository(); mockLocationVolumesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new LocationVolumesBusinessWorkflow(mockLocationVolumesRepository.Object, new LocationVolumeMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }