Ejemplo n.º 1
0
        public void TestPathNames()
        {
            string path;

            //path = Path_.RelativePath(@"A:\dir\subdir\file.ext", @"A:\dir");
            //Assert.Equal(@".\subdir\file.ext", path);

            path = Path_.CombinePath(@"A:\", @".\dir\subdir2", @"..\subdir\", "file.ext");
            Assert.Equal(@"A:\dir\subdir\file.ext", path);

            path = Path_.SanitiseFileName("1_path@\"[{+\\!@#$%^^&*()\'/?", "@#$%", "A");
            Assert.Equal("1_pathAA[{+A!AAAA^^&A()'AA", path);

            const string noquotes   = "C:\\a b\\path.ext";
            const string withquotes = "\"C:\\a b\\path.ext\"";

            Assert.Equal(withquotes, Path_.Quote(noquotes, true));
            Assert.Equal(withquotes, Path_.Quote(withquotes, true));
            Assert.Equal(noquotes, Path_.Quote(noquotes, false));
            Assert.Equal(noquotes, Path_.Quote(withquotes, false));
        }