示例#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));
        }
示例#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));
        }
示例#3
0
        public void RedNodeWithBulkMethodOnRoot()
        {
            var redRoot = this.root.AsRoot;
            RootedFileSystemDirectory modifiedRoot = redRoot.With(pathSegment: "g");

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

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

            Assert.Equal("c:", drive.PathSegment);
            Assert.True(drive.IsRoot);
            Assert.Equal(drive, drive.Root);
        }
示例#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);
        }
示例#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);
                }
            }
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }