Ejemplo n.º 1
0
        public Task Delete(Guid id)
        {
            var node = _libraryView.Get(id);

            if (node is LibraryFileNode)
            {
                return(Task.Factory.StartNew(() =>
                {
                    _library.DeleteFile(id);
                    _libraryView.DeleteNode(id);
                }));
            }

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

            return(Task.Factory.StartNew(() =>
            {
                foreach (var childNode in allChildren)
                {
                    _library.DeleteFile(childNode.Id);
                    _libraryView.DeleteNode(childNode.Id);
                }
                _libraryView.DeleteNode(id);
            }));
        }
Ejemplo n.º 2
0
        public void FilesCanBeDeleted()
        {
            var item = _ops.AddFile(_data, "test", new[] { "new" }, _time, @"the\test\path");

            Reload();
            var isPresent = _ops.Binaries.Any(b => b.Id == item.Id);

            _ops.DeleteFile(item.Id);
            Reload();
            var hasBeenDeleted = _ops.Binaries.All(b => b.Id != item.Id);

            var format   = "Was present: {0}    Was deleted: {1}";
            var expected = string.Format(format, true, true);
            var actual   = string.Format(format, isPresent, hasBeenDeleted);

            Assert.That(actual, Is.EqualTo(expected));
        }