public void RemoveDescendent()
        {
            FileSystemDirectory subdir          = this.root.OfType <FileSystemDirectory>().First(d => d.Children.OfType <FileSystemFile>().Any());
            FileSystemFile      fileUnderSubdir = subdir.Children.OfType <FileSystemFile>().First();
            FileSystemDirectory updatedRoot     = this.root.RemoveDescendent(fileUnderSubdir);

            Assert.Equal(this.root.Identity, updatedRoot.Identity);
            FileSystemDirectory updatedSubdir = (FileSystemDirectory)updatedRoot.Single(c => c.Identity == subdir.Identity);

            Assert.False(updatedSubdir.Contains(fileUnderSubdir));
        }
        public void AddDescendent()
        {
            FileSystemDirectory subdir      = this.root.OfType <FileSystemDirectory>().First();
            FileSystemFile      newLeaf     = FileSystemFile.Create("added.txt");
            FileSystemDirectory updatedRoot = this.root.AddDescendent(newLeaf, subdir);

            Assert.Equal(this.root.Identity, updatedRoot.Identity);
            FileSystemDirectory updatedSubdir = updatedRoot.OfType <FileSystemDirectory>().First();

            Assert.True(updatedSubdir.Contains(newLeaf));
        }
        public void AddDescendentWithLookupTableFixup()
        {
            var root = this.GetRootWithLookupTable();
            FileSystemDirectory subdir      = root.OfType <FileSystemDirectory>().First();
            FileSystemFile      newLeaf     = FileSystemFile.Create("added.txt");
            FileSystemDirectory updatedRoot = root.AddDescendent(newLeaf, subdir);

            Assert.Equal(root.Identity, updatedRoot.Identity);
            FileSystemDirectory updatedSubdir = updatedRoot.OfType <FileSystemDirectory>().First();

            Assert.True(updatedSubdir.Contains(newLeaf));
        }