Esempio n. 1
0
        public static void AddVSProject(Form owner)
        {
            TestLoader     loader = Services.TestLoader;
            OpenFileDialog dlg    = new OpenFileDialog();

            dlg.Title = "Add Visual Studio Project";

            dlg.Filter =
                "All Project Types (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
                "C# Projects (*.csproj)|*.csproj|" +
                "J# Projects (*.vjsproj)|*.vjsproj|" +
                "VB Projects (*.vbproj)|*.vbproj|" +
                "C++ Projects (*.vcproj)|*.vcproj|" +
                "All Files (*.*)|*.*";

            dlg.FilterIndex = 1;
            dlg.FileName    = "";

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                try
                {
                    VSProject vsProject = new VSProject(dlg.FileName);
                    loader.TestProject.Add(vsProject);
                }
                catch (Exception ex)
                {
                    UserMessage.DisplayFailure(ex.Message, "Invalid VS Project");
                }
            }
        }
Esempio n. 2
0
        private void okButton_Click(object sender, System.EventArgs e)
        {
            string path = assemblyPathTextBox.Text;

            try
            {
                FileInfo info = new FileInfo(path);

                if (!info.Exists)
                {
                    DialogResult answer = UserMessage.Ask(string.Format(
                                                              "The path {0} does not exist. Do you want to use it anyway?", path));
                    if (answer != DialogResult.Yes)
                    {
                        return;
                    }
                }

                DialogResult = DialogResult.OK;
                this.path    = path;
                this.Close();
            }
            catch (System.Exception exception)
            {
                assemblyPathTextBox.SelectAll();
                UserMessage.DisplayFailure(exception, "Invalid Entry");
            }
        }
Esempio n. 3
0
        public static void SaveLastResult(Form owner)
        {
            //TODO: Save all results
            TestLoader loader = Services.TestLoader;

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title            = "Save Test Results as XML";
            dlg.Filter           = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
            dlg.FileName         = "TestResult.xml";
            dlg.InitialDirectory = Path.GetDirectoryName(loader.TestFileName);
            dlg.DefaultExt       = "xml";
            dlg.ValidateNames    = true;
            dlg.OverwritePrompt  = true;

            if (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                try
                {
                    string fileName = dlg.FileName;

                    loader.SaveLastResult(fileName);

                    string msg = String.Format("Results saved as {0}", fileName);
                    UserMessage.DisplayInfo(msg, "Save Results as XML");
                }
                catch (Exception exception)
                {
                    UserMessage.DisplayFailure(exception, "Unable to Save Results");
                }
            }
        }
Esempio n. 4
0
 private void okButton_Click(object sender, System.EventArgs e)
 {
     configurationName = configurationNameTextBox.Text;
     if (project.Configs.Contains(configurationName))
     {
         // TODO: Need general error message display
         UserMessage.DisplayFailure("A configuration with that name already exists", "Configuration Name Error");
     }
     else
     {
         DialogResult = DialogResult.OK;
         Close();
     }
 }
Esempio n. 5
0
        public static void AddToProject(Form owner, string configName)
        {
            TestLoader    loader = Services.TestLoader;
            ProjectConfig config = configName == null
                                ? loader.TestProject.ActiveConfig
                                : loader.TestProject.Configs[configName];

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title            = "Add Assemblies To Project";
            dlg.InitialDirectory = config.BasePath;

            if (VisualStudioSupport)
            {
                dlg.Filter =
                    "Projects & Assemblies(*.csproj,*.vbproj,*.vjsproj, *.vcproj,*.dll,*.exe )|*.csproj;*.vjsproj;*.vbproj;*.vcproj;*.dll;*.exe|" +
                    "Visual Studio Projects (*.csproj,*.vjsproj,*.vbproj,*.vcproj)|*.csproj;*.vjsproj;*.vbproj;*.vcproj|" +
                    "C# Projects (*.csproj)|*.csproj|" +
                    "J# Projects (*.vjsproj)|*.vjsproj|" +
                    "VB Projects (*.vbproj)|*.vbproj|" +
                    "C++ Projects (*.vcproj)|*.vcproj|" +
                    "Assemblies (*.dll,*.exe)|*.dll;*.exe";
            }
            else
            {
                dlg.Filter = "Assemblies (*.dll,*.exe)|*.dll;*.exe";
            }

            dlg.FilterIndex = 1;
            dlg.FileName    = "";

            if (dlg.ShowDialog(owner) != DialogResult.OK)
            {
                return;
            }

            if (PathUtils.IsAssemblyFileType(dlg.FileName))
            {
                config.Assemblies.Add(dlg.FileName);
                return;
            }
            else if (VSProject.IsProjectFile(dlg.FileName))
            {
                try
                {
                    VSProject         vsProject = new VSProject(dlg.FileName);
                    MessageBoxButtons buttons;
                    string            msg;

                    if (configName != null && vsProject.Configs.Contains(configName))
                    {
                        msg = "The project being added may contain multiple configurations;\r\r" +
                              "Select\tYes to add all configurations found.\r" +
                              "\tNo to add only the " + configName + " configuration.\r" +
                              "\tCancel to exit without modifying the project.";
                        buttons = MessageBoxButtons.YesNoCancel;
                    }
                    else
                    {
                        msg = "The project being added may contain multiple configurations;\r\r" +
                              "Select\tOK to add all configurations found.\r" +
                              "\tCancel to exit without modifying the project.";
                        buttons = MessageBoxButtons.OKCancel;
                    }

                    DialogResult result = UserMessage.Ask(msg, buttons);
                    if (result == DialogResult.Yes || result == DialogResult.OK)
                    {
                        loader.TestProject.Add(vsProject);
                        return;
                    }
                    else if (result == DialogResult.No)
                    {
                        foreach (string assembly in vsProject.Configs[configName].Assemblies)
                        {
                            config.Assemblies.Add(assembly);
                        }
                        return;
                    }
                }
                catch (Exception ex)
                {
                    UserMessage.DisplayFailure(ex.Message, "Invalid VS Project");
                }
            }
        }