Exemplo n.º 1
0
        public void TestMoveToSamePathWithSlash()
        {
            var randomDirectoryName   = Path.GetRandomFileName();
            var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName) + @"\";
            var di = new DirectoryInfo(tempLongPathDirectory);

            Assert.Throws <IOException>(() => di.MoveTo(tempLongPathDirectory));
        }
Exemplo n.º 2
0
        public void TestMoveToNullPath()
        {
            var randomDirectoryName   = Path.GetRandomFileName();
            var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName);
            var di = new DirectoryInfo(tempLongPathDirectory);

            Assert.Throws <ArgumentNullException>(() => di.MoveTo(null));
        }
Exemplo n.º 3
0
        public void TestMoveToDifferentRoot()
        {
            var randomDirectoryName   = Path.GetRandomFileName();
            var tempLongPathDirectory = uncDirectory.Combine(randomDirectoryName);
            var di = new DirectoryInfo(tempLongPathDirectory);

            Assert.Throws <IOException>(() => di.MoveTo(@"D:\"));
        }
Exemplo n.º 4
0
        public void TestMoveToEmptyPath()
        {
            var randomDirectoryName   = Path.GetRandomFileName();
            var tempLongPathDirectory = longPathDirectory.Combine(randomDirectoryName);
            var di = new DirectoryInfo(tempLongPathDirectory);

            Assert.Throws <ArgumentException>(() => di.MoveTo(String.Empty));
        }
Exemplo n.º 5
0
        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());
        }