public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockVolumeLocationsRepository = VolumeLocationsMockingSetup.DoMockingSetupForRepository();
     mockVolumeLocationsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     var mockVolumeLocationsMapper = new Mock<IVolumeLocationMapper>();
     mockVolumeLocationsMapper.Setup(m => m.AreEqual(It.IsAny<IVolumeLocationModel>(), It.IsAny<IVolumeLocation>())).Returns(() => true);
     var businessWorkflow = new VolumeLocationsBusinessWorkflow(mockVolumeLocationsRepository.Object, mockVolumeLocationsMapper.Object);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
Exemple #2
0
        public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockVolumeLocationsRepository = VolumeLocationsMockingSetup.DoMockingSetupForRepository();

            mockVolumeLocationsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var mockVolumeLocationsMapper = new Mock <IVolumeLocationMapper>();

            mockVolumeLocationsMapper.Setup(m => m.AreEqual(It.IsAny <IVolumeLocationModel>(), It.IsAny <IVolumeLocation>())).Returns(() => true);
            var businessWorkflow = new VolumeLocationsBusinessWorkflow(mockVolumeLocationsRepository.Object, mockVolumeLocationsMapper.Object);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST"));
        }
Exemple #3
0
        public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockVolumeLocationsRepository = VolumeLocationsMockingSetup.DoMockingSetupForRepository();
            var mockVolumeLocationsMapper     = new Mock <IVolumeLocationMapper>();

            mockVolumeLocationsMapper.Setup(m => m.AreEqual(It.IsAny <IVolumeLocationModel>(), It.IsAny <IVolumeLocation>())).Returns(() => true);
            var businessWorkflow = new VolumeLocationsBusinessWorkflow(mockVolumeLocationsRepository.Object, mockVolumeLocationsMapper.Object);

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

            // Assert
            mockVolumeLocationsRepository.Verify(m => m.Deactivate(It.IsAny <IVolumeLocation>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockVolumeLocationsRepository = VolumeLocationsMockingSetup.DoMockingSetupForRepository();
     var mockVolumeLocationsMapper = new Mock<IVolumeLocationMapper>();
     mockVolumeLocationsMapper.Setup(m => m.AreEqual(It.IsAny<IVolumeLocationModel>(), It.IsAny<IVolumeLocation>())).Returns(() => true);
     var businessWorkflow = new VolumeLocationsBusinessWorkflow(mockVolumeLocationsRepository.Object, mockVolumeLocationsMapper.Object);
     mockVolumeLocationsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<IVolumeLocation>().Object);
     mockVolumeLocationsRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockVolumeLocationsRepository.Verify(m => m.Deactivate(It.IsAny<IVolumeLocation>()), Times.Once);
     Assert.Equal(true, result);
 }