Esempio n. 1
0
        public void AlphaFS_Host_GetHostShareFromPath()
        {
            Console.WriteLine("Network.Host.GetHostShareFromPath\n");

            var uncPath      = UnitTestConstants.SysRoot32;
            var hostAndShare = Host.GetHostShareFromPath(uncPath);

            Console.WriteLine("Input local path: [{0}]", uncPath);
            Assert.AreEqual(null, hostAndShare);

            uncPath      = Path.GetLongPath(UnitTestConstants.SysRoot32);
            hostAndShare = Host.GetHostShareFromPath(uncPath);
            Console.WriteLine("Input local path: [{0}]", uncPath);
            Assert.AreEqual(null, hostAndShare);

            Console.WriteLine();

            uncPath      = Path.LocalToUnc(UnitTestConstants.SysRoot32);
            hostAndShare = Host.GetHostShareFromPath(uncPath);
            Console.WriteLine("Input UNC path: [{0}]", uncPath);
            Console.WriteLine("\tHost : [{0}]", hostAndShare[0]);
            Console.WriteLine("\tShare: [{0}]", hostAndShare[1]);

            Assert.AreEqual(Environment.MachineName, hostAndShare[0].ToUpperInvariant());

            Console.WriteLine();

            uncPath      = Path.LocalToUnc(UnitTestConstants.SysRoot32, true);
            hostAndShare = Host.GetHostShareFromPath(uncPath);
            Console.WriteLine("Input UNC path: [{0}]", uncPath);
            Console.WriteLine("\tHost : [{0}]", hostAndShare[0]);
            Console.WriteLine("\tShare: [{0}]", hostAndShare[1]);

            Assert.AreEqual(Environment.MachineName, hostAndShare[0].ToUpperInvariant());
        }
Esempio n. 2
0
        public void AlphaFS_Path_GetLongPath()
        {
            Console.WriteLine("Path.GetLongPath()");

            var pathCnt  = 0;
            var errorCnt = 0;

            UnitTestConstants.StopWatcher(true);
            foreach (var path in UnitTestConstants.InputPaths)
            {
                string actual = null;

                Console.WriteLine("\n#{0:000}\tInput Path: [{1}]", ++pathCnt, path);

                // AlphaFS
                try
                {
                    actual = Path.GetLongPath(path);

                    if (Path.IsUncPath(path))
                    {
                        Assert.IsTrue(actual.StartsWith(Path.LongPathUncPrefix), "Path should start with a long unc path prefix.");
                    }
                    else
                    {
                        var c = path[0];
                        if (!Path.IsPathRooted(path) && ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
                        {
                            Assert.IsFalse(actual.StartsWith(Path.LongPathPrefix), "Path should not start with a long path prefix.");
                        }
                        else
                        {
                            if (!Path.IsPathRooted(path) && !Utils.IsNullOrWhiteSpace(Path.GetDirectoryName(path)))
                            {
                                Assert.IsTrue(actual.StartsWith(Path.LongPathUncPrefix), "Path should start with a long path prefix.");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("\tCaught [AlphaFS] {0}: [{1}]", ex.GetType().FullName, ex.Message.Replace(Environment.NewLine, "  "));

                    errorCnt++;
                }
                Console.WriteLine("\t   AlphaFS   : [{0}]", actual ?? "null");
            }
            Console.WriteLine("\n{0}", UnitTestConstants.Reporter(true));

            Assert.AreEqual(0, errorCnt, "No errors were expected.");
        }
Esempio n. 3
0
        public void MoveTo(string destDirName)
        {
            if (null == destDirName)
            {
                throw new ArgumentNullException("destDirName");
            }

            if (Directory.Exists(destDirName))
            {
                throw new AlreadyExistsException(destDirName);
            }

            File.Move(FullPath, Path.GetLongPath(destDirName), MoveFileOptions.CopyAllowed);
            Initialize(destDirName);
        }
Esempio n. 4
0
 public void MoveTo(string destFileName)
 {
     File.Move(FullPath, Path.GetLongPath(destFileName));
     Initialize(destFileName);
 }
Esempio n. 5
0
 public FileInfo CopyTo(string destFileName, bool overwrite)
 {
     File.Copy(FullPath, Path.GetLongPath(destFileName), overwrite);
     return(new FileInfo(destFileName));
 }
Esempio n. 6
0
 public FileInfo CopyTo(string destFileName)
 {
     File.Copy(FullPath, Path.GetLongPath(destFileName), false);
     return(new FileInfo(destFileName));
 }