Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
0
        public void MovePDBFile_SameNameandFileAlreadyExists()
        {
            string tempDirectory = Path.Combine(Path.GetTempPath(), "MovePDBFile_SmeNameandFileAlreadyExists");
            try
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }

                Directory.CreateDirectory(tempDirectory);

                string outputAssemblyPath = Path.Combine(tempDirectory, "Out.dll");
                string newoutputAssemblyPath = Path.Combine(tempDirectory, "Out.pdb");

                File.WriteAllText(outputAssemblyPath, "Hello");
                File.WriteAllText(newoutputAssemblyPath, "Hello");

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

                FileInfo newPDBInfo = new FileInfo(newoutputAssemblyPath);

                Assert.IsTrue(newPDBInfo.Exists);
                ((MockEngine)t.BuildEngine).MockLogger.AssertNoErrors();
            }
            finally
            {
                if (Directory.Exists(tempDirectory))
                {
                    FileUtilities.DeleteDirectoryNoThrow(tempDirectory, true);
                }
            }
        }