Ejemplo n.º 1
0
        public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
        {
            // Arrange
            var mockCharacterPowersRepository = CharacterPowersMockingSetup.DoMockingSetupForRepository();

            mockCharacterPowersRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var businessWorkflow = new CharacterPowersBusinessWorkflow(mockCharacterPowersRepository.Object, new CharacterPowerMapper());
            // Act
            var result = businessWorkflow.Remove("DOESNT-EXIST");

            // Assert
            Assert.Equal(true, result);
        }
Ejemplo n.º 2
0
        public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockCharacterPowersRepository = CharacterPowersMockingSetup.DoMockingSetupForRepository();
            var mockCharacterPowersMapper     = new Mock <ICharacterPowerMapper>();

            mockCharacterPowersMapper.Setup(m => m.AreEqual(It.IsAny <ICharacterPowerModel>(), It.IsAny <ICharacterPower>())).Returns(() => true);
            var businessWorkflow = new CharacterPowersBusinessWorkflow(mockCharacterPowersRepository.Object, mockCharacterPowersMapper.Object);

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

            // Assert
            mockCharacterPowersRepository.Verify(m => m.Remove(It.IsAny <ICharacterPower>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockCharacterPowersRepository = CharacterPowersMockingSetup.DoMockingSetupForRepository();
     var mockCharacterPowersMapper = new Mock<ICharacterPowerMapper>();
     mockCharacterPowersMapper.Setup(m => m.AreEqual(It.IsAny<ICharacterPowerModel>(), It.IsAny<ICharacterPower>())).Returns(() => true);
     var businessWorkflow = new CharacterPowersBusinessWorkflow(mockCharacterPowersRepository.Object, mockCharacterPowersMapper.Object);
     mockCharacterPowersRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<ICharacterPower>().Object);
     mockCharacterPowersRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Remove("KING-STEPHEN");
     // Assert
     mockCharacterPowersRepository.Verify(m => m.Remove(It.IsAny<ICharacterPower>()), Times.Once);
     Assert.Equal(true, result);
 }
 public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
 {
     // Arrange
     var mockCharacterPowersRepository = CharacterPowersMockingSetup.DoMockingSetupForRepository();
     mockCharacterPowersRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null);
     var businessWorkflow = new CharacterPowersBusinessWorkflow(mockCharacterPowersRepository.Object, new CharacterPowerMapper());
     // Act
     var result = businessWorkflow.Remove("DOESNT-EXIST");
     // Assert
     Assert.Equal(true, result);
 }