Example #1
0
 public void CloneTest()
 {
     var filePath = new FilePath(DirectoryPath.OS.Temp, "Test.txt");
     {
         var cloneFilePath = filePath.Clone();
         Assert.Equal(filePath.Value, cloneFilePath.Value);
         Assert.Equal(filePath.Extension, cloneFilePath.Extension);
         Assert.Equal(filePath.FileName, cloneFilePath.FileName);
         Assert.Equal(filePath.FileNameWithoutExtension, cloneFilePath.FileNameWithoutExtension);
         Assert.Equal(filePath.FullPath, cloneFilePath.FullPath);
         Assert.Equal(filePath.HasExtension, cloneFilePath.HasExtension);
         Assert.Equal((string)filePath, (string)cloneFilePath);
     }
     {
         var cloneFilePath = filePath.Clone("Clone.cln");
         Assert.Equal(filePath.DirectoryName, cloneFilePath.DirectoryName);
         Assert.Equal((string)filePath.Directory, (string)cloneFilePath.Directory);
         Assert.Equal((string)DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);
         Assert.Equal("Test.txt", filePath.FileName);
         Assert.Equal("Test", filePath.FileNameWithoutExtension);
         Assert.Equal(".txt", filePath.Extension);
         Assert.Equal("Clone.cln", cloneFilePath.FileName);
         Assert.Equal("Clone", cloneFilePath.FileNameWithoutExtension);
         Assert.Equal(".cln", cloneFilePath.Extension);
     }
 }
Example #2
0
        public void Implements_ICloneable()
        {
            string   fileExtension     = "dll";
            string   fileName          = "MPT.FileSystem.UnitTests";
            string   originalDirectory = _assemblyFolder;
            string   originalPath      = System.IO.Path.Combine(_assemblyFolder, fileName + "." + fileExtension);
            FilePath filePath          = new FilePath(originalPath);

            filePath.SetPathChildStub("Foo");
            filePath.IsSelected = true;
            FilePath clonedFilePath = (FilePath)filePath.Clone();


            Assert.AreEqual(filePath.Directory, clonedFilePath.Directory);
            Assert.AreEqual(filePath.FileName, clonedFilePath.FileName);
            Assert.AreEqual(filePath.FileExtension, clonedFilePath.FileExtension);
            Assert.AreEqual(filePath.FileNameWithExtension, clonedFilePath.FileNameWithExtension);
            Assert.AreEqual(filePath.PathChildStub, clonedFilePath.PathChildStub);
            Assert.AreEqual(filePath.Path(), clonedFilePath.Path());

            // Check empty, valid, and invalid relative paths
            Assert.AreEqual(filePath.Path(originalDirectory), clonedFilePath.Path(originalDirectory));
            Assert.AreEqual(filePath.Path(""), clonedFilePath.Path(""));
            Assert.AreEqual(filePath.Path(@"C:\Foo\Bar"), clonedFilePath.Path(@"C:\Foo\Bar"));
            Assert.AreEqual(filePath.Path(@"D:\Foo\Bar"), clonedFilePath.Path(@"D:\Foo\Bar"));

            Assert.AreEqual(filePath.IsDirectoryOnly, clonedFilePath.IsDirectoryOnly);
            Assert.AreEqual(filePath.IsFileNameOnly, clonedFilePath.IsFileNameOnly);
            Assert.AreEqual(filePath.IsValidPath, clonedFilePath.IsValidPath);


            Assert.AreNotEqual(filePath.IsSelected, clonedFilePath.IsSelected);
        }
Example #3
0
 public void CloneTestDateTime()
 {
     var TestTextFilePath = new FilePath(DirectoryPath.OS.Temp, "Test.txt");
     {
         {
             var cloneFilePath = TestTextFilePath.Clone().ChangeFileNameWithoutExtensionAppend(FilePath.DateTimeFormat.yyyyMMdd);
             if (cloneFilePath.FileWileNameWithoutExtensionLastAsDateTime() is var result && result.Ok)
             {
                 Assert.Equal(DateTime.Now.Date, result.Value.Date);
             }
Example #4
0
        //=====================================================================

        /// <summary>
        /// Clone this table of contents entry
        /// </summary>
        /// <returns>A clone of this table of contents entry</returns>
        public object Clone()
        {
            TocEntry clone = new TocEntry(pathProvider);

            clone.DestinationFile = this.DestinationFile;
            clone.IsDefaultTopic  = false;  // Can't have more than one
            clone.SortOrder       = this.SortOrder;
            clone.SourceFile      = (FilePath)sourceFile.Clone();
            clone.Title           = this.Title;

            foreach (TocEntry child in children)
            {
                clone.Children.Add((TocEntry)child.Clone());
            }

            return(clone);
        }
Example #5
0
        //=====================================================================

        /// <summary>
        /// Clone this table of contents entry
        /// </summary>
        /// <returns>A clone of this table of contents entry</returns>
        public object Clone()
        {
            TocEntry clone = new TocEntry(pathProvider);

            clone.DestinationFile = this.DestinationFile;
            clone.HasCodeBlocks   = this.HasCodeBlocks;
            clone.HasLinks        = this.HasLinks;
            clone.HasProjectTags  = this.HasProjectTags;
            clone.IncludePage     = this.IncludePage;
            clone.IsDefaultTopic  = false;  // Can't have more than one
            clone.NeedsColorizing = this.NeedsColorizing;
            clone.SortOrder       = this.SortOrder;
            clone.SourceFile      = (FilePath)sourceFile.Clone();
            clone.Title           = this.Title;

            foreach (TocEntry child in children)
            {
                clone.Children.Add((TocEntry)child.Clone());
            }

            return(clone);
        }