Exemplo n.º 1
0
        public void TestRenameOfRenamedProjectFile()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                string projectName    = project.GetMkDocument();
                string newprojectName = Path.Combine(project.ProjectFolder, Path.GetFileNameWithoutExtension(projectName) + "_temp");

                // Rename the project file on disk
                File.Move(projectName, newprojectName);

                // Now rename it within the solution explorer. This will popup the dialog box that the file cannot be renamed.
                // We are going to catch that dialog box.
                string resourceText = Utilities.GetResourceStringFromTheProjectAssembly("FileOrFolderCannotBeFound");

                string message = String.Format(System.Globalization.CultureInfo.CurrentCulture, resourceText, project.ProjectFile);

                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, "NewFileName", message), "The messagebox for not being able to rename a file that has been deleted has never popped up");
            });
        }
Exemplo n.º 2
0
        private void TestBadFileNameForSetEditLabel(ProjectNode project)
        {
            string errorMessage = Utilities.GetResourceStringFromTheProjectAssembly("ErrorInvalidFileName");

            foreach (string newBadFileName in Utilities.BadFileNames)
            {
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, newBadFileName, errorMessage), "The file named " + newBadFileName + " could be saved as");
            }

            string badFileName = "  ";

            Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

            badFileName = "..\\" + project.ProjectFile;
            Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

            badFileName = "....";
            Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

            errorMessage = String.Format(System.Globalization.CultureInfo.CurrentCulture, Utilities.GetResourceStringFromTheProjectAssembly("PathTooLong"), Utilities.LongFileName);
            Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(project, Utilities.LongFileName, errorMessage), "The file named " + Utilities.LongFileName + " could be saved");
        }
Exemplo n.º 3
0
        public void TestRenameWithBadFileName()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                FileNode fileNode     = null;
                List <FileNode> nodes = Utilities.GetNodesOfType <FileNode>(project);

                if (nodes.Count > 0)
                {
                    fileNode = nodes[0];
                }

                string errorMessage = Utilities.GetResourceStringFromTheProjectAssembly("ErrorInvalidFileName");

                foreach (string newBadFileName in Utilities.BadFileNames)
                {
                    Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, newBadFileName, errorMessage), "The file named " + newBadFileName + " could be saved as");
                }

                string badFileName = "  ";
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                badFileName = "..\\" + fileNode.FileName;
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                badFileName = "....";
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                errorMessage = String.Format(System.Globalization.CultureInfo.CurrentCulture, Utilities.GetResourceStringFromTheProjectAssembly("PathTooLong"), Utilities.LongFileName);
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, Utilities.LongFileName, errorMessage), "The file named " + Utilities.LongFileName + " could be saved");
            });
        }