예제 #1
0
파일: PathTest.cs 프로젝트: jdstroy/AlphaFS
        private void DumpGetDirectoryNameWithoutRoot(bool isLocal)
        {
            Console.WriteLine("\n=== TEST {0} ===", isLocal ? UnitTestConstants.Local : UnitTestConstants.Network);

            const string neDir = "Non-Existing Directory";
            const string sys32 = "system32";

            var fullPath = Path.Combine(Environment.SystemDirectory, neDir);

            if (!isLocal)
            {
                fullPath = Path.LocalToUnc(fullPath);
            }

            UnitTestConstants.StopWatcher(true);
            var directoryNameWithoutRoot = Path.GetDirectoryNameWithoutRoot(fullPath);

            Console.WriteLine("\nInput Path: [{0}]\n\tGetDirectoryNameWithoutRoot() (Should be: [{1}]): [{2}]", fullPath, sys32, directoryNameWithoutRoot);
            Assert.IsTrue(directoryNameWithoutRoot.Equals(sys32, StringComparison.OrdinalIgnoreCase));



            fullPath = Path.Combine(fullPath, "Non-Existing file.txt");
            if (!isLocal)
            {
                fullPath = Path.LocalToUnc(fullPath);
            }

            UnitTestConstants.StopWatcher(true);
            directoryNameWithoutRoot = Path.GetDirectoryNameWithoutRoot(fullPath);
            Console.WriteLine("\nInput Path: [{0}]\n\tGetDirectoryNameWithoutRoot() (Should be: [{1}]): [{2}]", fullPath, neDir, directoryNameWithoutRoot);
            Assert.IsTrue(directoryNameWithoutRoot.Equals(neDir, StringComparison.OrdinalIgnoreCase));



            fullPath = UnitTestConstants.SysRoot;
            if (!isLocal)
            {
                fullPath = Path.LocalToUnc(fullPath);
            }

            UnitTestConstants.StopWatcher(true);
            directoryNameWithoutRoot = Path.GetDirectoryNameWithoutRoot(fullPath);
            Console.WriteLine("\nInput Path: [{0}]\n\tGetDirectoryNameWithoutRoot() (Should be: [null]): [{1}]", fullPath, directoryNameWithoutRoot ?? "null");
            Assert.AreEqual(null, directoryNameWithoutRoot);

            Console.WriteLine("\n");
        }
예제 #2
0
파일: AlphaFSToys.cs 프로젝트: CDEApp/CDE
        public void GetDirectoryNameWithoutRoot_OnPathPrefixSlash()
        {
            var a = Path.GetDirectoryNameWithoutRoot(@"\Data");

            Assert.That(a, Is.EqualTo(null));
        }