public void Delete_should_do_nothing_if_user_not_found() { var characterDao = new Mock <ICharacterDao>(); characterDao.Setup(x => x.Load(It.IsAny <string>())).Returns(null as Character); ICharacterOperationService operationService = new CharacterOperationService(null, characterDao.Object); operationService.Delete("Zeratul"); characterDao.Verify(x => x.Save(It.IsAny <Character>()), Times.Never()); }
public void Delete_should_set_character_deleted_to_true() { var character = new Character { Name = "Zeratul", Deleted = false }; var characterDao = new Mock <ICharacterDao>(); characterDao.Setup(x => x.Load(It.IsAny <string>())).Returns(character); ICharacterOperationService operationService = new CharacterOperationService(null, characterDao.Object); operationService.Delete("Zeratul"); characterDao.Verify(x => x.Save(It.Is <Character>(c => c.Deleted && ReferenceEquals(character.Name, c.Name))), Times.Once); }