Пример #1
0
        public void MoveRootToAlternateChangesOnlyRoot()
        {
            var adj     = new PathAdjuster(_root, _alternate);
            var newPath = adj.AdjustPath(_rootChildren);

            Assert.That(PrintPath(newPath), Is.EqualTo(@"alternate\child\grandchild"));
        }
Пример #2
0
        public void MoveRootChildToOtherChildIsAdjustedCorrectly()
        {
            var adj     = new PathAdjuster(_rootChild, _rootOtherChildren);
            var newPath = adj.AdjustPath(_rootChildren);

            Assert.That(PrintPath(newPath), Is.EqualTo(@"root\otherchild\grandchild"));
        }
Пример #3
0
        public void RootPathIsAdded()
        {
            var adj     = new PathAdjuster(_emptyPath, _root);
            var newPath = adj.AdjustPath(_emptyPath);

            Assert.That(PrintPath(newPath), Is.EqualTo("root"));
        }
Пример #4
0
        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);
        }