Example #1
0
        public void SaveLastResult()
        {
            //TODO: Save all results
            TestResult result = loader.Results[0];

            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;

                    XmlResultVisitor resultVisitor
                        = new XmlResultVisitor(fileName, result);
                    result.Accept(resultVisitor);
                    resultVisitor.Write();

                    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");
                }
            }
        }
Example #2
0
        public static void SaveProjectAs(Form owner)
        {
            TestLoader loader = Services.TestLoader;

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Save Test Project";
            dlg.Filter = "NUnit Test Project (*.nunit)|*.nunit|All Files (*.*)|*.*";
            string path = NUnitProject.ProjectPathFromFile(loader.TestProject.ProjectPath);

            if (CanWriteProjectFile(path))
            {
                dlg.FileName = path;
            }
            dlg.DefaultExt      = "nunit";
            dlg.ValidateNames   = true;
            dlg.OverwritePrompt = true;

            while (dlg.ShowDialog(owner) == DialogResult.OK)
            {
                if (!CanWriteProjectFile(dlg.FileName))
                {
                    UserMessage.DisplayInfo(string.Format("File {0} is write-protected. Select another file name.", dlg.FileName));
                }
                else
                {
                    loader.TestProject.Save(dlg.FileName);
                    return;
                }
            }
        }
Example #3
0
        public void OpenProject(string testFileName, string configName, string testName)
        {
            if (loader.IsProjectLoaded && SaveProjectIfDirty() == DialogResult.Cancel)
            {
                return;
            }

            loader.LoadProject(testFileName, configName);
            if (loader.IsProjectLoaded)
            {
                NUnitProject testProject = loader.TestProject;
                if (testProject.Configs.Count == 0)
                {
                    UserMessage.DisplayInfo("Loaded project contains no configuration data");
                }
                else if (testProject.ActiveConfig == null)
                {
                    UserMessage.DisplayInfo("Loaded project has no active configuration");
                }
                else if (testProject.ActiveConfig.Assemblies.Count == 0)
                {
                    UserMessage.DisplayInfo("Active configuration contains no assemblies");
                }
                else
                {
                    loader.LoadTest(testName);
                }
            }
        }
Example #4
0
        public static void OpenProject(Form owner, string testFileName, string configName, string testName)
        {
            TestLoader loader = Services.TestLoader;

            if (loader.IsProjectLoaded && SaveProjectIfDirty(owner) == DialogResult.Cancel)
            {
                return;
            }

            loader.LoadProject(testFileName, configName);
            if (loader.IsProjectLoaded)
            {
                NUnitProject testProject = loader.TestProject;
                if (testProject.Configs.Count == 0)
                {
                    UserMessage.DisplayInfo("Loaded project contains no configuration data");
                }
                else if (testProject.ActiveConfig == null)
                {
                    UserMessage.DisplayInfo("Loaded project has no active configuration");
                }
                else if (testProject.ActiveConfig.Assemblies.Count == 0)
                {
                    UserMessage.DisplayInfo("Active configuration contains no assemblies");
                }
                else
                {
                    using (new LongRunningOperationDisplay(owner, "Loading..."))
                    {
                        loader.LoadTest(testName);
                    }
                }
            }
        }