Ejemplo n.º 1
0
        public void EditProject()
        {
            NUnitProject project = loader.TestProject;

            string editorPath = GetProjectEditorPath();

            if (!File.Exists(editorPath))
            {
                string NL      = Environment.NewLine;
                string message =
                    "Unable to locate the specified Project Editor:" + NL + NL + editorPath + NL + NL +
                    (Services.UserSettings.GetSetting("Options.ProjectEditor.EditorPath") == null
                        ? "Verify that nunit.editor.exe is properly installed in the NUnit bin directory."
                        : "Verify that you have set the path to the editor correctly.");

                Form.MessageDisplay.Error(message);

                return;
            }

            if (!NUnitProject.IsNUnitProjectFile(project.ProjectPath))
            {
                if (Form.MessageDisplay.Display(
                        "The project has not yet been saved. In order to edit the project, it must first be saved. Click OK to save the project or Cancel to exit.",
                        MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    project.Save();
                }
            }
            else if (!File.Exists(project.ProjectPath))
            {
                project.Save();
            }
            else if (project.IsDirty)
            {
                switch (Form.MessageDisplay.Ask(
                            "There are unsaved changes. Do you want to save them before running the editor?",
                            MessageBoxButtons.YesNoCancel))
                {
                case DialogResult.Yes:
                    project.Save();
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }

            // In case we tried to save project and failed
            if (NUnitProject.IsNUnitProjectFile(project.ProjectPath) && File.Exists(project.ProjectPath))
            {
                Process p = new Process();

                p.StartInfo.FileName  = Quoted(editorPath);
                p.StartInfo.Arguments = Quoted(project.ProjectPath);
                p.Start();
            }
        }
Ejemplo n.º 2
0
 public void SaveProject()
 {
     if (Path.IsPathRooted(loader.TestProject.ProjectPath) &&
         NUnitProject.IsNUnitProjectFile(loader.TestProject.ProjectPath) &&
         CanWriteProjectFile(loader.TestProject.ProjectPath))
     {
         loader.TestProject.Save();
     }
     else
     {
         SaveProjectAs();
     }
 }
Ejemplo n.º 3
0
        public static void SaveProject(Form owner)
        {
            TestLoader loader = Services.TestLoader;

            if (Path.IsPathRooted(loader.TestProject.ProjectPath) &&
                NUnitProject.IsNUnitProjectFile(loader.TestProject.ProjectPath) &&
                CanWriteProjectFile(loader.TestProject.ProjectPath))
            {
                loader.TestProject.Save();
            }
            else
            {
                SaveProjectAs(owner);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Helper method to determine if an IDataObject is valid
        /// for dropping on the tree view. It must be a the drop
        /// of a single file with a valid assembly file type.
        /// </summary>
        /// <param name="data">IDataObject to be tested</param>
        /// <returns>True if dropping is allowed</returns>
        private bool IsValidFileDrop(IDataObject data)
        {
            if (!data.GetDataPresent(DataFormats.FileDrop))
            {
                return(false);
            }

            string [] fileNames = data.GetData(DataFormats.FileDrop) as string [];

            if (fileNames == null || fileNames.Length == 0)
            {
                return(false);
            }

            // We can't open more than one project at a time
            // so handle length of 1 separately.
            if (fileNames.Length == 1)
            {
                string fileName  = fileNames[0];
                bool   isProject = NUnitProject.IsNUnitProjectFile(fileName);
                if (Services.UserSettings.GetSetting("Options.TestLoader.VisualStudioSupport", false))
                {
                    isProject |= Services.ProjectService.CanConvertFrom(fileName);
                }

                return(isProject || PathUtils.IsAssemblyFileType(fileName));
            }

            // Multiple assemblies are allowed - we
            // assume they are all in the same directory
            // since they are being dragged together.
            foreach (string fileName in fileNames)
            {
                if (!PathUtils.IsAssemblyFileType(fileName))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
 public void IsProjectFile()
 {
     Assert.IsTrue(NUnitProject.IsNUnitProjectFile(@"\x\y\test.nunit"));
     Assert.IsFalse(NUnitProject.IsNUnitProjectFile(@"\x\y\test.junit"));
 }