public void RedNodeRecursiveParentCreate()
        {
            var drive = RootedFileSystemDirectory.Create("c:");

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