示例#1
0
        public void FilesCanBeRenamed()
        {
            var item    = _ops.AddFile(_data, "test", new [] { "new" }, _time, @"the\test\path");
            var nameTag = item.NameTag;

            Reload();
            _ops.Rename(item.Id, "renamed");
            Reload();
            Assert.That(_ops.Binaries.First(b => b.Id == item.Id).NameTag, Is.GreaterThan(nameTag));
        }
        public Task Rename(Guid id, string newName)
        {
            var node = _libraryView.Get(id);

            if (node is LibraryFileNode)
            {
                return(Task.Factory.StartNew(() =>
                {
                    _library.Rename(id, newName);
                    node.Name = newName;
                }));
            }

            var allChildren = _libraryView.GetAllChildren(id).ToList();

            return(Task.Factory.StartNew(() =>
            {
                node.Name = newName;
                foreach (var libraryViewNode in allChildren)
                {
                    var path = GetPath(libraryViewNode.Parent);
                    _library.MoveFile(libraryViewNode.Id, path, libraryViewNode.Name);
                }
            }));
        }