Exemplo n.º 1
0
        public void ConformSeparator_ChangeAllBackToForward()
        {
            string filePath = @"C:\Files\stuff.txt";
            var    path     = new PathInfo(filePath);

            path.ConformSeparatorTo('/');

            var expected = @"C:/Files/stuff.txt";
            var actual   = path.FilePath;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void ConformSeparator_ChangeVariousToBack()
        {
            string filePath = @"C:\Files/Docs/thing.png";
            var    path     = new PathInfo(filePath);

            path.ConformSeparatorTo('\\');

            var expected = @"C:\Files\Docs\thing.png";
            var actual   = path.FilePath;

            Assert.AreEqual(expected, actual);
        }
        public void ExampleUsageForReadme()
        {
            string myPath   = @"C:\Users\Coder\Documents\Code\Project\File.cs";
            var    pathInfo = new PathInfo(myPath);

            pathInfo.ConformSeparatorTo('/');

            //Remove the filename (strip it back to directory only)
            pathInfo.SetFileName("");

            pathInfo.AddChunks(true, "src", "Controllers");
            pathInfo.SetFileName("FileNameController.cs");

            Assert.AreEqual(@"C:\Users\Coder\Documents\Code\Project\src\Controllers\FileNameController.cs", pathInfo.FilePath);

            string remotePath = "https://files.example/Coder/Documents/";
            string newPath    = PathMatcher.Resituate(pathInfo.FilePath, remotePath);

            string expected = "https://files.example/Coder/Documents/Code/Project/src/Controllers/FileNameController.cs";

            Assert.AreEqual(expected, newPath);
        }