Esempio n. 1
0
        public void MovePDBFile_GoodName()
        {
            string tempDirectory = Path.Combine(Path.GetTempPath(), "MovePDBFile_GoodName");

            try
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }

                Directory.CreateDirectory(tempDirectory);

                string outputAssemblyPath    = Path.Combine(tempDirectory, "Out.dll");
                string newoutputAssemblyPath = Path.Combine(tempDirectory, "MyNewPDBFile.pdb");
                string outputPDBPath         = Path.Combine(tempDirectory, "Out.pdb");
                File.WriteAllText(outputPDBPath, "Hello");
                File.WriteAllText(outputAssemblyPath, "Hello");

                Vbc t = new Vbc();
                t.BuildEngine = new MockEngine();
                t.PdbFile     = newoutputAssemblyPath;
                t.MovePdbFileIfNecessary(outputAssemblyPath);

                FileInfo newPDBInfo = new FileInfo(newoutputAssemblyPath);
                FileInfo oldPDBInfo = new FileInfo(outputPDBPath);

                Assert.IsTrue(newPDBInfo.Exists);
                Assert.IsFalse(oldPDBInfo.Exists);
                ((MockEngine)t.BuildEngine).MockLogger.AssertNoErrors();
            }
            finally
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }
            }
        }
Esempio n. 2
0
        public void MovePDBFile_BadFileName()
        {
            string tempDirectory = Path.Combine(Path.GetTempPath(), "MovePDBFile_BadFileName");

            try
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }

                Directory.CreateDirectory(tempDirectory);

                string outputAssemblyPath = Path.Combine(tempDirectory, "Out.dll");
                string outputPDBPath      = Path.Combine(tempDirectory, "Out.pdb");
                File.WriteAllText(outputPDBPath, "Hello");
                File.WriteAllText(outputAssemblyPath, "Hello");

                MockEngine engine = new MockEngine();
                Vbc        t      = new Vbc();
                t.BuildEngine = engine;
                t.PdbFile     = "||{}}{<>?$$%^&*()!@#$%`~.pdb";
                t.MovePdbFileIfNecessary(outputAssemblyPath);

                FileInfo oldPDBInfo = new FileInfo(outputAssemblyPath);
                Assert.IsTrue(oldPDBInfo.Exists);

                Assert.IsTrue(engine.Errors >= 1, "Should be one error");
                (t.BuildEngine as MockEngine).AssertLogContains("MSB3402");
            }
            finally
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }
            }
        }