Exemple #1
0
        public void ConvertRootedDirectoryToFile()
        {
            RootedFileSystemDirectory redDirectory = this.root.AsRoot.Children.Last().AsFileSystemDirectory;
            var redFile = redDirectory.ToFileSystemFile();

            Assert.True(redFile.Root.Children.Contains(redFile.AsFileSystemEntry));
        }
Exemple #2
0
        public void ConvertRootedFileToDirectory()
        {
            RootedFileSystemFile      redFile      = this.root.AsRoot.Children.First().AsFileSystemFile;
            RootedFileSystemDirectory redDirectory = redFile.ToFileSystemDirectory();

            Assert.True(redDirectory.Root.Children.Contains(redDirectory.AsFileSystemEntry));
        }
Exemple #3
0
        public void RedNodeWithBulkMethodOnRoot()
        {
            var redRoot = this.root.AsRoot;
            RootedFileSystemDirectory modifiedRoot = redRoot.With(pathSegment: "g");

            Assert.Equal("g", modifiedRoot.PathSegment);
        }
Exemple #4
0
        public void RootedStruct_IsDefault()
        {
            var file = new RootedFileSystemDirectory();

            Assert.True(file.IsDefault);
            file = FileSystemDirectory.Create("c:").AsRoot;
            Assert.False(file.IsDefault);
        }
Exemple #5
0
        public void RedNodeRecursiveParentCreate()
        {
            var drive = RootedFileSystemDirectory.Create("c:");

            Assert.Equal("c:", drive.PathSegment);
            Assert.True(drive.IsRoot);
            Assert.Equal(drive, drive.Root);
        }
Exemple #6
0
        public void RootedStruct_ImplicitConversionToGreenNode()
        {
            RootedFileSystemDirectory rootedDrive   = RootedFileSystemDirectory.Create("c:");
            FileSystemDirectory       unrootedDrive = rootedDrive;

            Assert.Same(rootedDrive.FileSystemDirectory, unrootedDrive);
            FileSystemEntry unrootedEntry = rootedDrive;

            Assert.Same(rootedDrive.FileSystemDirectory, unrootedEntry);
        }
Exemple #7
0
        private static void VerifyDescendentsShareRoot(RootedFileSystemDirectory directory)
        {
            foreach (var child in directory)
            {
                Assert.Same(directory.Root.FileSystemDirectory, child.Root.FileSystemDirectory);

                if (child.IsFileSystemDirectory)
                {
                    VerifyDescendentsShareRoot(child.AsFileSystemDirectory);
                }
            }
        }
Exemple #8
0
        public void RedNodeConstructionAPI()
        {
            var redRoot = RootedFileSystemDirectory.Create("c:").AddChildren(
                FileSystemFile.Create("a.cs"),
                FileSystemFile.Create("b.cs"),
                FileSystemDirectory.Create("c")
                .AddChildren(FileSystemFile.Create("d.cs")));

            Assert.Equal("c:", redRoot.PathSegment);
            Assert.Equal(3, redRoot.Children.Count);
            Assert.Equal("d.cs", redRoot.Children.Single(c => c.IsFileSystemDirectory).AsFileSystemDirectory.Children.Single().PathSegment);
        }
Exemple #9
0
        public void RedNodeStuff()
        {
            var redRoot = this.root.AsRoot;

            Assert.Equal(this.root.PathSegment, redRoot.PathSegment);
            Assert.Equal(this.root.Children.Count, redRoot.Children.Count);
            Assert.Contains(redRoot.Children, c => c.PathSegment == "a.cs" && c.IsFileSystemFile);
            Assert.Contains(redRoot.Children, c => c.PathSegment == "b.cs" && c.IsFileSystemFile);

            RootedFileSystemDirectory subdir = redRoot.Children.Last().AsFileSystemDirectory;

            Assert.Equal("d.cs", subdir.Children.Single().PathSegment);
        }
Exemple #10
0
        public void RootedStruct_EqualityOperators()
        {
            var r1a = RootedFileSystemDirectory.Create("foo");
            var r1b = r1a; // struct copy
            var r2  = RootedFileSystemDirectory.Create("foo");

            // Compare two structs with the same underlying green node reference.
            Assert.True(r1a == r1b);
            Assert.False(r1a != r1b);

            // Compare two structs with different underlying green node references.
            Assert.False(r1a == r2);
            Assert.True(r1a != r2);

            // Now verify the root node reference aspect to it.
            var newRoot = RootedFileSystemDirectory.Create("c:")
                          .AddChild(r1a.FileSystemDirectory).Parent;
            var r1Rerooted = r1a.FileSystemDirectory.WithRoot(newRoot);

            Assert.False(r1a == r1Rerooted);
            Assert.True(r1a != r1Rerooted);
        }