public void LoadViewFromModel()
        {
            view.Visible = true;

            view.ProjectPath.Text      = model.ProjectPath;
            view.ProjectBase.Text      = model.EffectiveBasePath;
            view.ActiveConfigName.Text = model.ActiveConfigName;

            view.ProcessModel.SelectedItem = model.ProcessModel;
            view.DomainUsage.SelectedItem  = model.DomainUsage;

            view.ConfigList.SelectionList = model.ConfigNames;
            if (model.ConfigNames.Length > 0)
            {
                view.ConfigList.SelectedIndex = 0;
                selectedConfig = model.Configs[0];
            }
            else
            {
                view.ConfigList.SelectedIndex = -1;
                selectedConfig = null;
            }

            //OnSelectedConfigChange();
        }
Exemple #2
0
        private void LoadViewFromModel()
        {
            _view.Visible = true;

            _view.ProjectPath.Text      = _model.ProjectPath;
            _view.ProjectBase.Text      = _model.EffectiveBasePath;
            _view.ActiveConfigName.Text = _model.ActiveConfigName;

            _view.ProcessModel.SelectedItem = _model.ProcessModel;
            _view.DomainUsage.SelectedItem  = _model.DomainUsage;

            _view.ConfigList.SelectionList = _model.ConfigNames;
            if (_model.ConfigNames.Length > 0)
            {
                _view.ConfigList.SelectedIndex = 0;
                _selectedConfig = _model.Configs[0];
            }
            else
            {
                _view.ConfigList.SelectedIndex = -1;
                _selectedConfig = null;
            }

            ConfigList_SelectionChanged();
        }
Exemple #3
0
        public void ProjectWithComplexSettings()
        {
            IProjectConfig config1 = project.AddConfig("Debug");

            config1.BasePath         = "debug";
            config1.BinPathType      = BinPathType.Auto;
            config1.RuntimeFramework = new RuntimeFramework(RuntimeType.Any, new Version(2, 0));
            config1.Assemblies.Add("assembly1.dll");
            config1.Assemblies.Add("assembly2.dll");

            IProjectConfig config2 = project.AddConfig("Release");

            config2.BasePath         = "release";
            config2.BinPathType      = BinPathType.Auto;
            config2.RuntimeFramework = new RuntimeFramework(RuntimeType.Any, new Version(4, 0));
            config2.Assemblies.Add("assembly1.dll");
            config2.Assemblies.Add("assembly2.dll");

            project.ActiveConfigName = "Release";
            project.BasePath         = "bin";
            project.ProcessModel     = "Separate";
            project.DomainUsage      = "Multiple";

            CheckContents(NUnitProjectXml.ComplexSettingsProject);
        }
        public void LoadViewFromModel()
        {
            view.Visible = true;

            view.ProjectPath.Text = model.ProjectPath;
            view.ProjectBase.Text = model.EffectiveBasePath;
            view.ActiveConfigName.Text = model.ActiveConfigName;

            view.ProcessModel.SelectedItem = model.ProcessModel;
            view.DomainUsage.SelectedItem = model.DomainUsage;

            view.ConfigList.SelectionList = model.ConfigNames;
            if (model.ConfigNames.Length > 0)
            {
                view.ConfigList.SelectedIndex = 0;
                selectedConfig = model.Configs[0];
            }
            else
            {
                view.ConfigList.SelectedIndex = -1;
                selectedConfig = null;
            }

            //OnSelectedConfigChange();
        }
Exemple #5
0
        public void RuntimeVersion_WhenTextChanged_UpdatesProject()
        {
            // Set to non-default values for this test
            IProjectConfig config = model.Configs[0];

            config.RuntimeFramework = new RuntimeFramework(RuntimeType.Net, new Version("2.0.50727"));

            view.RuntimeVersion.Text = "4.0";

            Assert.That(config.RuntimeFramework.Runtime, Is.EqualTo(RuntimeType.Net));
            Assert.That(config.RuntimeFramework.Version, Is.EqualTo(new Version(4, 0)));
        }
Exemple #6
0
        public void Runtime_WhenChanged_UpdatesProject()
        {
            // Set to non-default values for this test
            IProjectConfig config = model.Configs[0];

            config.RuntimeFramework = new RuntimeFramework(RuntimeType.Net, new Version("2.0.50727"));

            view.ConfigList.SelectedIndex = 0;
            view.Runtime.SelectedItem     = "Mono";

            Assert.That(config.RuntimeFramework.Runtime, Is.EqualTo(RuntimeType.Mono));
            Assert.That(config.RuntimeFramework.Version, Is.EqualTo(new Version("2.0.50727")));
        }
Exemple #7
0
        private void ConfigList_SelectionChanged()
        {
            IProjectConfig selectedConfig = _view.ConfigList.SelectedIndex >= 0
                ? _model.Configs[_view.ConfigList.SelectedIndex]
                : null;

            if (selectedConfig != null)
            {
                RuntimeFramework framework = selectedConfig.RuntimeFramework;
                _view.Runtime.SelectedItem = framework.Runtime.ToString();
                _view.RuntimeVersion.Text  = framework.Version == new Version()
                    ? string.Empty
                    : framework.Version.ToString();

                if (selectedConfig.BasePath == null)
                {
                    _view.ApplicationBase.Text = _model.EffectiveBasePath;
                }
                else
                {
                    _view.ApplicationBase.Text = PathUtils.RelativePath(
                        Path.Combine(_model.EffectiveBasePath, selectedConfig.BasePath),
                        selectedConfig.BasePath);
                }
                _view.ConfigurationFile.Text    = selectedConfig.ConfigurationFile;
                _view.BinPathType.SelectedIndex = (int)selectedConfig.BinPathType;
                if (selectedConfig.BinPathType == BinPathType.Manual)
                {
                    _view.PrivateBinPath.Text = selectedConfig.PrivateBinPath;
                }
                else
                {
                    _view.PrivateBinPath.Text = string.Empty;
                }

                SetAssemblyList();
            }
            else
            {
                _view.Runtime.SelectedItem = "Any";
                _view.RuntimeVersion.Text  = string.Empty;

                _view.ApplicationBase.Text      = null;
                _view.ConfigurationFile.Text    = string.Empty;
                _view.PrivateBinPath.Text       = string.Empty;
                _view.BinPathType.SelectedIndex = (int)BinPathType.Auto;

                _view.AssemblyList.SelectionList = new string[0];
                _view.AssemblyPath.Text          = string.Empty;
            }
        }
Exemple #8
0
        public AddConfigurationPresenter(IProjectModel model, IAddConfigurationDialog dlg)
        {
            this.model = model;
            this.dlg   = dlg;

            dlg.ConfigList = model.ConfigNames;

            dlg.OkButton.Execute += delegate
            {
                if (dlg.ConfigToCreate == string.Empty)
                {
                    dlg.MessageDisplay.Error("No configuration name provided");
                    return;
                }

                foreach (string config in model.ConfigNames)
                {
                    if (config == dlg.ConfigToCreate)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                IProjectConfig newConfig = model.AddConfig(dlg.ConfigToCreate);

                if (dlg.ConfigToCopy != null)
                {
                    IProjectConfig copyConfig = model.Configs[dlg.ConfigToCopy];
                    if (copyConfig != null)
                    {
                        newConfig.BasePath    = copyConfig.BasePath;
                        newConfig.BinPathType = copyConfig.BinPathType;
                        if (newConfig.BinPathType == BinPathType.Manual)
                        {
                            newConfig.PrivateBinPath = copyConfig.PrivateBinPath;
                        }
                        newConfig.ConfigurationFile = copyConfig.ConfigurationFile;
                        newConfig.RuntimeFramework  = copyConfig.RuntimeFramework;

                        foreach (string assembly in copyConfig.Assemblies)
                        {
                            newConfig.Assemblies.Add(assembly);
                        }
                    }
                }

                dlg.Close();
            };
        }
        public void LoadProjectWithManualBinPath()
        {
            project.LoadXml(NUnitProjectXml.ManualBinPathProject);

            //Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
            //Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);

            Assert.AreEqual(1, project.Configs.Count);

            IProjectConfig config1 = project.Configs["Debug"];

            Assert.AreEqual("Debug", config1.Name);
            Assert.AreEqual(1, config1.Settings.Count);
            Assert.AreEqual("bin_path_value", config1.Settings["PrivateBinPath"]);
        }
Exemple #10
0
        public void LoadProjectWithManualBinPath()
        {
            doc.LoadXml(NUnitProjectXml.ManualBinPathProject);

            Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);

            Assert.AreEqual(null, project.BasePath);
            Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);

            Assert.AreEqual("Default", project.ProcessModel);
            Assert.AreEqual("Default", project.DomainUsage);

            Assert.AreEqual(1, project.Configs.Count);
            Assert.AreEqual(new string[] { "Debug" }, project.ConfigNames);

            IProjectConfig config1 = project.Configs["Debug"];

            Assert.AreEqual("bin_path_value", config1.PrivateBinPath);
        }
        /// <summary>
        /// Expands a TestPackages based on a known project format,
        /// creating a subpackage for each assembly. The FilePath
        /// of hte package must be checked to ensure that it is
        /// a known project format before calling this method.
        /// </summary>
        /// <param name="package">The TestPackage to be expanded</param>
        public void ExpandProjectPackage(TestPackage package)
        {
            IProject project = LoadProject(package.FullName);

            string         configName = package.GetSetting(RunnerSettings.ActiveConfig, string.Empty); // Need RunnerSetting
            IProjectConfig config     = configName != string.Empty
                ? project.Configs[configName]
                : project.ActiveConfig;

            foreach (string key in config.Settings.Keys)
            {
                package.Settings[key] = config.Settings[key];
            }

            foreach (string assembly in config.Assemblies)
            {
                package.Add(assembly);
            }
        }
Exemple #12
0
        public Project(IProjectConfig config, IEnumerable<SourceScript> scripts)
        {
            if (config == null)
                throw new ArgumentNullException("config");
            if (scripts == null)
                throw new ArgumentNullException("scripts");

            var allScripts = scripts.ToList();

            Configuration = config;
            _nonPriorityScripts = allScripts.ToList();
            _allScriptsLookup = allScripts.ToDictionary(s => s.Name.ToLower(), s => s, StringComparer.OrdinalIgnoreCase);
            _priorityScripts = new List<SourceScript>();
            SetupPriorityScripts();

            var orderedList = _nonPriorityScripts.OrderBy(x => x.Name).ToList();
            var builder = new DependencyListBuilder<string, SourceScript>(orderedList);
            _nonPriorityScripts = builder.BuildDependencyList(script => script.Name, script => script.GetNeeds(), StringComparer.OrdinalIgnoreCase);
        }
        private void OnSelectedConfigChange()
        {
            IProjectConfig selectedConfig = view.ConfigList.SelectedIndex >= 0
                ? model.Configs[view.ConfigList.SelectedIndex]
                : null;

            if (selectedConfig != null)
            {
                RuntimeFramework framework = selectedConfig.RuntimeFramework;
                view.Runtime.SelectedItem = framework.Runtime.ToString();
                view.RuntimeVersion.Text  = framework.Version == new Version()
                    ? string.Empty
                    : framework.Version.ToString();

                view.ApplicationBase.Text      = selectedConfig.RelativeBasePath;
                view.ConfigurationFile.Text    = selectedConfig.ConfigurationFile;
                view.BinPathType.SelectedIndex = (int)selectedConfig.BinPathType;
                if (selectedConfig.BinPathType == BinPathType.Manual)
                {
                    view.PrivateBinPath.Text = selectedConfig.PrivateBinPath;
                }
                else
                {
                    view.PrivateBinPath.Text = string.Empty;
                }

                SetAssemblyList();
            }
            else
            {
                view.Runtime.SelectedItem = "Any";
                view.RuntimeVersion.Text  = string.Empty;

                view.ApplicationBase.Text      = null;
                view.ConfigurationFile.Text    = string.Empty;
                view.PrivateBinPath.Text       = string.Empty;
                view.BinPathType.SelectedIndex = (int)BinPathType.Auto;

                view.AssemblyList.SelectionList = new string[0];
                view.AssemblyPath.Text          = string.Empty;
            }
        }
        public void LoadProjectWithComplexSettings()
        {
            project.LoadXml(NUnitProjectXml.ComplexSettingsProject);

            Assert.AreEqual(2, project.Configs.Count);

            IProjectConfig config1 = project.Configs["Debug"];

            Assert.AreEqual(5, config1.Settings.Count);
            Assert.AreEqual("bin" + SEP + "debug", config1.Settings["BasePath"]);
            Assert.AreEqual(true, config1.Settings["AutoBinPath"]);
            Assert.AreEqual("Separate", config1.Settings["ProcessModel"]);
            Assert.AreEqual("Multiple", config1.Settings["DomainUsage"]);
            Assert.AreEqual("v2.0", config1.Settings["RuntimeFramework"]);

            Assert.AreEqual(2, config1.Assemblies.Length);
            Assert.AreEqual(
                "bin" + SEP + "debug" + SEP + "assembly1.dll",
                config1.Assemblies[0]);
            Assert.AreEqual(
                "bin" + SEP + "debug" + SEP + "assembly2.dll",
                config1.Assemblies[1]);

            IProjectConfig config2 = project.Configs["Release"];

            Assert.AreEqual(5, config2.Settings.Count);
            Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
            Assert.AreEqual("Separate", config2.Settings["ProcessModel"]);
            Assert.AreEqual("Multiple", config2.Settings["DomainUsage"]);
            Assert.AreEqual("v4.0", config2.Settings["RuntimeFramework"]);

            Assert.AreEqual(2, config2.Assemblies.Length);
            Assert.AreEqual(
                "bin" + SEP + "release",
                config2.Settings["BasePath"]);
            Assert.AreEqual(
                "bin" + SEP + "release" + SEP + "assembly1.dll",
                config2.Assemblies[0]);
            Assert.AreEqual(
                "bin" + SEP + "release" + SEP + "assembly2.dll",
                config2.Assemblies[1]);
        }
Exemple #15
0
        public void NormalProject()
        {
            IProjectConfig config1 = project.AddConfig("Debug");

            config1.BasePath    = "bin" + Path.DirectorySeparatorChar + "debug";
            config1.BinPathType = BinPathType.Auto;
            config1.Assemblies.Add("assembly1.dll");
            config1.Assemblies.Add("assembly2.dll");

            IProjectConfig config2 = project.AddConfig("Release");

            config2.BasePath    = "bin" + Path.DirectorySeparatorChar + "release";
            config2.BinPathType = BinPathType.Auto;
            config2.Assemblies.Add("assembly1.dll");
            config2.Assemblies.Add("assembly2.dll");

            project.ActiveConfigName = "Debug";

            CheckContents(NUnitProjectXml.NormalProject);
        }
Exemple #16
0
        private void SetAssemblyList()
        {
            IProjectConfig config = _model.Configs[_view.ConfigList.SelectedIndex];
            var            list   = new string[config.Assemblies.Count];

            for (int i = 0; i < list.Length; i++)
            {
                list[i] = config.Assemblies[i];
            }

            _view.AssemblyList.SelectionList = list;
            if (list.Length > 0)
            {
                _view.AssemblyList.SelectedIndex = 0;
                _view.AssemblyPath.Text          = list[0];
            }
            else
            {
                _view.AssemblyList.SelectedIndex = -1;
                _view.AssemblyPath.Text          = string.Empty;
            }
        }
Exemple #17
0
        public void LoadProjectWithComplexSettings()
        {
            doc.LoadXml(NUnitProjectXml.ComplexSettingsProject);
            Assert.AreEqual("bin", project.BasePath);
            Assert.AreEqual("Separate", project.ProcessModel);
            Assert.AreEqual("Multiple", project.DomainUsage);

            Assert.AreEqual(2, project.Configs.Count);

            IProjectConfig config1 = project.Configs[0];

            Assert.AreEqual(
                "debug",
                config1.BasePath);
            Assert.AreEqual(RuntimeType.Any, config1.RuntimeFramework.Runtime);
            Assert.AreEqual("2.0", config1.RuntimeFramework.Version.ToString(2));
            Assert.AreEqual(2, config1.Assemblies.Count);
            Assert.AreEqual(
                "assembly1.dll",
                config1.Assemblies[0]);
            Assert.AreEqual(
                "assembly2.dll",
                config1.Assemblies[1]);

            IProjectConfig config2 = project.Configs[1];

            Assert.AreEqual(2, config2.Assemblies.Count);
            Assert.AreEqual(
                "release",
                config2.BasePath);
            Assert.AreEqual(RuntimeType.Any, config2.RuntimeFramework.Runtime);
            Assert.AreEqual("4.0", config2.RuntimeFramework.Version.ToString(2));
            Assert.AreEqual(
                "assembly1.dll",
                config2.Assemblies[0]);
            Assert.AreEqual(
                "assembly2.dll",
                config2.Assemblies[1]);
        }
        public void LoadEmptyConfigs()
        {
            project.LoadXml(NUnitProjectXml.EmptyConfigs);

            //Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
            //Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);

            Assert.AreEqual(2, project.Configs.Count);
            Assert.AreEqual("Debug", project.ActiveConfig.Name);

            IProjectConfig config1 = project.Configs["Debug"];

            Assert.AreEqual("Debug", config1.Name);
            Assert.AreEqual(1, config1.Settings.Count);
            Assert.AreEqual(true, config1.Settings["AutoBinPath"]);

            IProjectConfig config2 = project.Configs["Release"];

            Assert.AreEqual("Release", config2.Name);
            Assert.AreEqual(1, config2.Settings.Count);
            Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
        }
        public void LoadNormalProject()
        {
            project.LoadXml(NUnitProjectXml.NormalProject);

            //Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
            //Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);

            Assert.AreEqual(2, project.Configs.Count);
            Assert.AreEqual("Debug", project.ActiveConfig.Name);

            IProjectConfig config1 = project.Configs["Debug"];

            Assert.AreEqual(2, config1.Assemblies.Length);
            Assert.AreEqual(
                "bin" + SEP + "debug" + SEP + "assembly1.dll",
                config1.Assemblies[0]);
            Assert.AreEqual(
                "bin" + SEP + "debug" + SEP + "assembly2.dll",
                config1.Assemblies[1]);

            Assert.AreEqual(2, config1.Settings.Count);
            Assert.AreEqual("bin" + SEP + "debug", config1.Settings["BasePath"]);
            Assert.AreEqual(true, config1.Settings["AutoBinPath"]);

            IProjectConfig config2 = project.Configs["Release"];

            Assert.AreEqual(2, config2.Assemblies.Length);
            Assert.AreEqual(
                "bin" + SEP + "release" + SEP + "assembly1.dll",
                config2.Assemblies[0]);
            Assert.AreEqual(
                "bin" + SEP + "release" + SEP + "assembly2.dll",
                config2.Assemblies[1]);

            Assert.AreEqual(2, config2.Settings.Count);
            Assert.AreEqual("bin" + SEP + "release", config2.Settings["BasePath"]);
            Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
        }
        private void UpdateApplicationBase(string appbase)
        {
            string basePath = null;

            if (appbase != String.Empty)
            {
                basePath = Path.Combine(model.BasePath, appbase);
                if (PathUtils.SamePath(model.BasePath, basePath))
                {
                    basePath = null;
                }
            }

            IProjectConfig selectedConfig = model.Configs[view.ConfigList.SelectedIndex];

            view.ApplicationBase.Text = selectedConfig.BasePath = basePath;

            // TODO: Test what happens if we set it the same as doc base
            //if (index.RelativeBasePath == null)
            //    applicationBaseTextBox.Text = string.Empty;
            //else
            //    applicationBaseTextBox.Text = index.RelativeBasePath;
        }
Exemple #21
0
        public void LoadNormalProject()
        {
            doc.LoadXml(NUnitProjectXml.NormalProject);

            Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);

            Assert.AreEqual(null, project.BasePath);
            Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);

            Assert.AreEqual("Default", project.ProcessModel);
            Assert.AreEqual("Default", project.DomainUsage);

            Assert.AreEqual(2, project.Configs.Count);
            Assert.AreEqual(new string[] { "Debug", "Release" }, project.ConfigNames);

            Assert.AreEqual("Debug", project.ActiveConfigName);

            IProjectConfig config1 = project.Configs[0];

            Assert.AreEqual(2, config1.Assemblies.Count);
            Assert.AreEqual(
                "assembly1.dll",
                config1.Assemblies[0]);
            Assert.AreEqual(
                "assembly2.dll",
                config1.Assemblies[1]);

            IProjectConfig config2 = project.Configs[1];

            Assert.AreEqual(2, config2.Assemblies.Count);
            Assert.AreEqual(
                "assembly1.dll",
                config2.Assemblies[0]);
            Assert.AreEqual(
                "assembly2.dll",
                config2.Assemblies[1]);
        }
Exemple #22
0
        public Project(IProjectConfig config, IEnumerable <SourceScript> scripts)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (scripts == null)
            {
                throw new ArgumentNullException("scripts");
            }

            var allScripts = scripts.ToList();

            Configuration       = config;
            _nonPriorityScripts = allScripts.ToList();
            _allScriptsLookup   = allScripts.ToDictionary(s => s.Name.ToLower(), s => s, StringComparer.OrdinalIgnoreCase);
            _priorityScripts    = new List <SourceScript>();
            SetupPriorityScripts();

            var orderedList = _nonPriorityScripts.OrderBy(x => x.Name).ToList();
            var builder     = new DependencyListBuilder <string, SourceScript>(orderedList);

            _nonPriorityScripts = builder.BuildDependencyList(script => script.Name, script => script.GetNeeds(), StringComparer.OrdinalIgnoreCase);
        }
        private void LoadViewFromModel()
        {
            _view.Visible = true;

            _view.ProjectPath.Text = _model.ProjectPath;
            _view.ProjectBase.Text = _model.EffectiveBasePath;
            _view.ActiveConfigName.Text = _model.ActiveConfigName;

            _view.ProcessModel.SelectedItem = _model.ProcessModel;
            _view.DomainUsage.SelectedItem = _model.DomainUsage;

            _view.ConfigList.SelectionList = _model.ConfigNames;
            if (_model.ConfigNames.Length > 0)
            {
                _view.ConfigList.SelectedIndex = 0;
                _selectedConfig = _model.Configs[0];
            }
            else
            {
                _view.ConfigList.SelectedIndex = -1;
                _selectedConfig = null;
            }

            ConfigList_SelectionChanged();
        }