Example #1
0
        public void Clones_Deep()
        {
            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.CloneStatic();


            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);
        }