public void TestMoveToSamePathWithSlash() { var randomDirectoryName = Path.GetRandomFileName(); var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName) + @"\"; var di = new DirectoryInfo(tempLongPathDirectory); Assert.Throws <IOException>(() => di.MoveTo(tempLongPathDirectory)); }
public void TestMoveToNullPath() { var randomDirectoryName = Path.GetRandomFileName(); var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName); var di = new DirectoryInfo(tempLongPathDirectory); Assert.Throws <ArgumentNullException>(() => di.MoveTo(null)); }
public void TestMoveToDifferentRoot() { var randomDirectoryName = Path.GetRandomFileName(); var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName); var di = new DirectoryInfo(tempLongPathDirectory); Assert.Throws <IOException>(() => di.MoveTo(@"D:\")); }
public void TestMoveToEmptyPath() { var randomDirectoryName = Path.GetRandomFileName(); var tempLongPathDirectory = longPathDirectory.Combine(randomDirectoryName); var di = new DirectoryInfo(tempLongPathDirectory); Assert.Throws <ArgumentException>(() => di.MoveTo(String.Empty)); }
public void TestMoveTo() { var randomFileName = Path.GetRandomFileName(); var randomFileName2 = Path.GetRandomFileName(); var tempLongPathFilename = uncDirectory.Combine(randomFileName); var tempLongPathFilename2 = uncDirectory.Combine(randomFileName2); tempLongPathFilename.CreateDirectory(); try { var di = new DirectoryInfo(tempLongPathFilename); di.MoveTo(tempLongPathFilename2); di = new DirectoryInfo(uncDirectory); var dirs = di.EnumerateDirectories("*", SearchOption.TopDirectoryOnly).ToArray(); Assert.AreEqual(1, dirs.Length); Assert.IsTrue(dirs.Any(f => f.Name == randomFileName2)); Assert.IsFalse(dirs.Any(f => f.Name == randomFileName)); } finally { Pri.LongPath.Directory.Delete(tempLongPathFilename2); } Assert.IsFalse(tempLongPathFilename.Exists()); }