public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
     mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     var mockCharacterEnemiesMapper = new Mock<ICharacterEnemyMapper>();
     mockCharacterEnemiesMapper.Setup(m => m.AreEqual(It.IsAny<ICharacterEnemyModel>(), It.IsAny<ICharacterEnemy>())).Returns(() => true);
     var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, mockCharacterEnemiesMapper.Object);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
示例#2
0
        public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();

            mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => null);
            var mockCharacterEnemiesMapper = new Mock <ICharacterEnemyMapper>();

            mockCharacterEnemiesMapper.Setup(m => m.AreEqual(It.IsAny <ICharacterEnemyModel>(), It.IsAny <ICharacterEnemy>())).Returns(() => true);
            var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, mockCharacterEnemiesMapper.Object);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
        }
示例#3
0
        public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
            var mockCharacterEnemiesMapper     = new Mock <ICharacterEnemyMapper>();

            mockCharacterEnemiesMapper.Setup(m => m.AreEqual(It.IsAny <ICharacterEnemyModel>(), It.IsAny <ICharacterEnemy>())).Returns(() => true);
            var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, mockCharacterEnemiesMapper.Object);

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

            // Assert
            mockCharacterEnemiesRepository.Verify(m => m.Deactivate(It.IsAny <ICharacterEnemy>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
     var mockCharacterEnemiesMapper = new Mock<ICharacterEnemyMapper>();
     mockCharacterEnemiesMapper.Setup(m => m.AreEqual(It.IsAny<ICharacterEnemyModel>(), It.IsAny<ICharacterEnemy>())).Returns(() => true);
     var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, mockCharacterEnemiesMapper.Object);
     mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<ICharacterEnemy>().Object);
     mockCharacterEnemiesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockCharacterEnemiesRepository.Verify(m => m.Deactivate(It.IsAny<ICharacterEnemy>()), Times.Once);
     Assert.Equal(true, result);
 }