示例#1
0
        public void TestEnumerateDirectoriesWithSearchRecursiveNoResults()
        {
            var tempLongPathFilename = longPathDirectory.Combine(Path.GetRandomFileName());

            tempLongPathFilename.CreateDirectory();

            try {
                var di = new DirectoryInfo(longPathDirectory);
                Assert.AreEqual(0, di.EnumerateDirectories("gibberish*", SearchOption.AllDirectories).Count());
            }
            finally {
                Directory.Delete(tempLongPathFilename);
            }
        }
示例#2
0
        public void TestEnumerateDirectoriesWithWildcardSearchAndOptionNoResults()
        {
            var tempLongPathFilename = uncDirectory.Combine(Path.GetRandomFileName());

            tempLongPathFilename.CreateDirectory();

            try {
                var di = new DirectoryInfo(uncDirectory);
                Assert.AreEqual(0, di.EnumerateDirectories("gibberish*", SearchOption.TopDirectoryOnly).Count());
            }
            finally {
                Pri.LongPath.Directory.Delete(tempLongPathFilename);
            }
        }
示例#3
0
        public void TestEnumerateDirectoriesWithSearchWithNoResults()
        {
            var randomFileName       = Path.GetRandomFileName();
            var tempLongPathFilename = uncDirectory.Combine(randomFileName);

            tempLongPathFilename.CreateDirectory();

            try {
                var di   = new DirectoryInfo(uncDirectory);
                var dirs = di.EnumerateDirectories("gibberish").ToArray();
                Assert.AreEqual(0, dirs.Length);
            }
            finally {
                Pri.LongPath.Directory.Delete(tempLongPathFilename);
            }
        }
示例#4
0
        public void TestRecursiveEnumerateDirectoriesWithSearchNoResults()
        {
            var randomFileName       = Path.GetRandomFileName();
            var tempLongPathFilename = longPathDirectory.Combine(randomFileName);

            tempLongPathFilename.CreateDirectory();

            try {
                var di   = new DirectoryInfo(longPathDirectory);
                var dirs = di.EnumerateDirectories("gibberish", SearchOption.AllDirectories).ToArray();
                Assert.AreEqual(0, dirs.Length);
            }
            finally {
                Directory.Delete(tempLongPathFilename);
            }
        }
示例#5
0
        public void TestEnumerateDirectoriesWithSearchRecursive()
        {
            var randomFileName       = Path.GetRandomFileName();
            var tempLongPathFilename = uncDirectory.Combine(randomFileName);

            tempLongPathFilename.CreateDirectory();

            try {
                var di   = new DirectoryInfo(uncDirectory);
                var dirs = di.EnumerateDirectories("*", SearchOption.AllDirectories).ToArray();
                Assert.AreEqual(1, dirs.Length);
                Assert.IsTrue(dirs.Any(f => f.Name == randomFileName));
            }
            finally {
                Pri.LongPath.Directory.Delete(tempLongPathFilename);
            }
        }
示例#6
0
        public void TestEnumerateDirectories()
        {
            var randomFileName       = Path.GetRandomFileName();
            var tempLongPathFilename = longPathDirectory.Combine(randomFileName);

            tempLongPathFilename.CreateDirectory();

            try {
                var di   = new DirectoryInfo(longPathDirectory);
                var dirs = di.EnumerateDirectories().ToArray();
                Assert.AreEqual(1, dirs.Length);
                Assert.IsTrue(dirs.Any(f => f.Name == randomFileName));
            }
            finally {
                Directory.Delete(tempLongPathFilename);
            }
        }
示例#7
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());
        }