public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository(); mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_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.Remove("KING-STEPHEN"); // Assert mockCharacterEnemiesRepository.Verify(m => m.Remove(It.IsAny <ICharacterEnemy>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_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.Remove("KING-STEPHEN"); // Assert mockCharacterEnemiesRepository.Verify(m => m.Remove(It.IsAny<ICharacterEnemy>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository(); mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }