public void MoveRootToAlternateChangesOnlyRoot() { var adj = new PathAdjuster(_root, _alternate); var newPath = adj.AdjustPath(_rootChildren); Assert.That(PrintPath(newPath), Is.EqualTo(@"alternate\child\grandchild")); }
public void MoveRootChildToOtherChildIsAdjustedCorrectly() { var adj = new PathAdjuster(_rootChild, _rootOtherChildren); var newPath = adj.AdjustPath(_rootChildren); Assert.That(PrintPath(newPath), Is.EqualTo(@"root\otherchild\grandchild")); }
public void RootPathIsAdded() { var adj = new PathAdjuster(_emptyPath, _root); var newPath = adj.AdjustPath(_emptyPath); Assert.That(PrintPath(newPath), Is.EqualTo("root")); }
public Task Move(LibraryViewNode node, LibraryViewNode newParent) { if (node is LibraryFileNode) { return(Task.Factory.StartNew(() => { _library.MoveFile(node.Id, newParent.GetPathForChild(), node.Name); if (node.Parent != null) { node.Parent.Children.Remove(node); } node.Parent = newParent; newParent.Children.Add(node); })); } if (node is LibraryFolderNode) { return(Task.Factory.StartNew(() => { var adjuster = new PathAdjuster(node.Path, newParent.GetPathForChild()); foreach (var child in GetAllChildren(node)) { var newPath = adjuster.AdjustPath(child.Path); _library.MoveFile(child.Id, newPath, child.Name); } if (node.Parent != null) { node.Parent.Children.Remove(node); } else { _libraryView.Items.Remove(node); } node.Parent = newParent; newParent.Children.Add(node); })); } return(null); }