private static void DumpPathFileExists(string path, bool doesExist)
        {
            Console.WriteLine("\n\tPath: [{0}]\n", path);

            bool fileExists = Shell32.PathFileExists(path);

            Console.WriteLine("\t\tShell32.PathFileExists() == [{0}]: {1}\t\t[{2}]", doesExist ? TextTrue : TextFalse, doesExist == fileExists, path);
            Console.WriteLine("\t\tFile.Exists()            == [{0}]: {1}\t\t[{2}]", doesExist ? TextTrue : TextFalse, doesExist == File.Exists(path), path);
            Console.WriteLine("\t\tDirectory.Exists()       == [{0}]: {1}\t\t[{2}]", doesExist ? TextTrue : TextFalse, doesExist == Directory.Exists(path), path);

            if (doesExist)
            {
                Assert.IsTrue(fileExists);
            }

            if (!doesExist)
            {
                Assert.IsTrue(!fileExists);
            }
        }
        public void PathFileExists()
        {
            Console.WriteLine("Filesystem.Shell32.PathFileExists()");

            string path = SysRoot;

            DumpPathFileExists(path, true);
            DumpPathFileExists(Path.LocalToUnc(path), true);
            DumpPathFileExists("BlaBlaBla", false);
            DumpPathFileExists(Path.Combine(SysRoot, "BlaBlaBla"), false);

            int cnt = 0;

            StopWatcher(true);
            foreach (string file in Directory.EnumerateFiles(SysRoot))
            {
                bool fileExists = Shell32.PathFileExists(file);

                Console.WriteLine("\t#{0:000}\tShell32.PathFileExists() == [{1}]: {2}\t\t[{3}]", ++cnt, TextTrue, fileExists, file);
                Assert.IsTrue(fileExists);
            }
            Console.WriteLine("\n\t{0}\n", Reporter(true));
        }
Exemplo n.º 3
0
        public void AlphaFS_Shell32_PathFileExists()
        {
            Console.WriteLine("Filesystem.Shell32.PathFileExists()");

            var path = UnitTestConstants.SysRoot;

            DumpPathFileExists(path, true);
            DumpPathFileExists(Path.LocalToUnc(path), true);
            DumpPathFileExists("BlaBlaBla", false);
            DumpPathFileExists(Path.Combine(UnitTestConstants.SysRoot, "BlaBlaBla"), false);

            var cnt = 0;

            UnitTestConstants.StopWatcher(true);
            foreach (var file in Directory.EnumerateFiles(UnitTestConstants.SysRoot))
            {
                var fileExists = Shell32.PathFileExists(file);

                Console.WriteLine("\t#{0:000}\tShell32.PathFileExists() == [{1}]: {2}\t\t[{3}]", ++cnt, UnitTestConstants.TextTrue, fileExists, file);
                Assert.IsTrue(fileExists);
            }
            Console.WriteLine("\n\t{0}\n", UnitTestConstants.Reporter(true));
        }