Exemplo n.º 1
0
        public void IsAbsolutePath_Windows()
        {
            var pal = new WinPAL();

            Assert(!pal.IsAbsolutePath(null));
            Assert(!pal.IsAbsolutePath(""));
            Assert(!pal.IsAbsolutePath("C"));
            Assert(!pal.IsAbsolutePath(@"\"));
            Assert(!pal.IsAbsolutePath(@"/"));
            Assert(!pal.IsAbsolutePath(@":"));
            Assert(!pal.IsAbsolutePath(@"\:"));
            Assert(!pal.IsAbsolutePath(@"/:"));
            Assert(!pal.IsAbsolutePath(@"XX:"));

            // current working directory relative
            Assert(!pal.IsAbsolutePath(@"."));
            Assert(!pal.IsAbsolutePath(@".\"));
            Assert(!pal.IsAbsolutePath(@"./"));
            Assert(!pal.IsAbsolutePath(@".."));
            Assert(!pal.IsAbsolutePath(@"..\"));
            Assert(!pal.IsAbsolutePath(@"../"));

            // Drive relative
            Assert(!pal.IsAbsolutePath(@"C:"));

            // Drive
            Assert(pal.IsAbsolutePath(@"C:\"));
            Assert(pal.IsAbsolutePath(@"C:/"));
            Assert(pal.IsAbsolutePath(@"C:\path"));

            // UNC
            Assert(pal.IsAbsolutePath(@"\/"));
            Assert(pal.IsAbsolutePath(@"\\"));
            Assert(pal.IsAbsolutePath(@"/\"));
            Assert(pal.IsAbsolutePath(@"//"));

            // relative to the current user:
            Assert(!pal.IsAbsolutePath(@"~\path"));
        }
        public void IsAbsolutePath_Windows()
        {
            var pal = new WinPAL();

            Assert(!pal.IsAbsolutePath(null));
            Assert(!pal.IsAbsolutePath(""));
            Assert(!pal.IsAbsolutePath("C"));
            Assert(!pal.IsAbsolutePath(@"\"));
            Assert(!pal.IsAbsolutePath(@"/"));
            Assert(!pal.IsAbsolutePath(@":"));
            Assert(!pal.IsAbsolutePath(@"\:"));
            Assert(!pal.IsAbsolutePath(@"/:"));
            Assert(!pal.IsAbsolutePath(@"XX:"));

            // current working directory relative
            Assert(!pal.IsAbsolutePath(@"."));
            Assert(!pal.IsAbsolutePath(@".\"));
            Assert(!pal.IsAbsolutePath(@"./"));
            Assert(!pal.IsAbsolutePath(@".."));
            Assert(!pal.IsAbsolutePath(@"..\"));
            Assert(!pal.IsAbsolutePath(@"../"));

            // Drive relative
            Assert(!pal.IsAbsolutePath(@"C:"));

            // Drive
            Assert(pal.IsAbsolutePath(@"C:\"));
            Assert(pal.IsAbsolutePath(@"C:/"));
            Assert(pal.IsAbsolutePath(@"C:\path"));

            // UNC
            Assert(pal.IsAbsolutePath(@"\/"));
            Assert(pal.IsAbsolutePath(@"\\"));
            Assert(pal.IsAbsolutePath(@"/\"));
            Assert(pal.IsAbsolutePath(@"//"));

            // relative to the current user:
            Assert(!pal.IsAbsolutePath(@"~\path"));
        }