示例#1
0
        public void TestPathValidation()
        {
            Assert.True(Path_.IsValidDirectory(@"A:\dir1\..\.\dir2", true));
            Assert.True(Path_.IsValidDirectory(@"A:\dir1\..\.\dir2", false));
            Assert.True(Path_.IsValidDirectory(@".\dir1\..\.\dir2", false));
            Assert.True(Path_.IsValidDirectory(@"A:\dir1\..\.\dir2\", true));
            Assert.True(Path_.IsValidDirectory(@"A:\dir1\..\.\dir2\", false));
            Assert.True(Path_.IsValidDirectory(@".\dir1\..\.\dir2\", false));
            Assert.False(Path_.IsValidDirectory(@".\dir1?\..\.\", false));

            Assert.True(Path_.IsValidFilepath(@"A:\dir1\..\.\dir2\file.txt", true));
            Assert.True(Path_.IsValidFilepath(@"A:\dir1\..\.\dir2\file", false));
            Assert.True(Path_.IsValidFilepath(@".\dir1\..\.\dir2\file", false));
            Assert.False(Path_.IsValidFilepath(@".\dir1\", false));
            Assert.False(Path_.IsValidFilepath(@".\dir1\file*.txt", false));

            Assert.False(Path_.IsValidFilepath(@"A:\dump\file.tx##:t", false));
            Assert.False(Path_.IsValidFilepath(@"A:\dump\fi:.txt", false));
            Assert.False(Path_.IsValidFilepath(@"A:\dump\f*.txt", false));
            Assert.False(Path_.IsValidFilepath(@"A:\dump\f?.txt", false));
        }