public void RejectedRenameDoesntChangeAnything() { var service = new TestRenameService(this.Persistence.Favorites, newName => false); var customCommand = new FavoriteRenameCommand(this.Persistence, service); bool performAction = customCommand.ValidateNewName(this.copy, ORIGINAL_NAME); Assert.IsFalse(performAction, "Favorite cant be changed, if user refused the rename."); }
public void InitializeFavorites() { this.AddFavorite(ORIGINAL_NAME); this.copy = this.AddFavorite(COPY_NAME); // command is set to rename by default var service = new TestRenameService(this.Persistence.Favorites, newName => true); this.command = new FavoriteRenameCommand(this.Persistence, service); }
public void NoDuplicitDoesntAskUser() { bool asked = false; var service = new TestRenameService(this.Persistence.Favorites, newName => { asked = true; return true; }); var customCommand = new FavoriteRenameCommand(this.Persistence, service); customCommand.ApplyRename(this.copy, RENAMED_NAME); Assert.IsFalse(asked, "If there is no duplicit, user shouldnt be prompter."); }
internal CopyFavoriteCommand(IPersistence persistence, Func<InputBoxResult> copyPrompt = null) { this.favorites = persistence.Favorites; var renameService = new RenameCopyService(persistence.Favorites); renameService.RenameAction = this.AddIfValid; // property injection this.renameCommand = new FavoriteRenameCommand(persistence, renameService); if (copyPrompt != null) this.copyPrompt = copyPrompt; else this.copyPrompt = () => InputBox.Show("Enter new name:", "Duplicate selected favorite as ..."); }
private void FavsList_Load(object sender, EventArgs e) { this.favsTree.Persistence = this.Persistence; this.treeLoader = new FavoriteTreeListLoader(this.favsTree, this.Persistence); this.treeLoader.LoadRootNodes(); this.historyTreeView.Load(this.Persistence); this.LoadState(); this.favsTree.MouseUp += new MouseEventHandler(this.FavsTree_MouseUp); this.searchTextBox.LoadEvents(this.Persistence); // hadle events this.searchPanel1.LoadEvents(this.Persistence); this.renameCommand = new FavoriteRenameCommand(this.Persistence, new RenameService(this.Persistence.Favorites)); }
private void ApplyNewName(string newName) { var renameService = new RenameService(this.PersistedFavorites); var updateCommand = new FavoriteRenameCommand(this.persistence, renameService); bool newNameValid = updateCommand.ValidateNewName(this.editedFavorite, newName); if (!newNameValid) return; updateCommand.ApplyRename(this.editedFavorite, newName); this.UpdateFavoritesBindingSource(); }