Beispiel #1
0
        /// <summary>
        /// Expands a TestPackage based on a known project format, populating it
        /// with the project contents and any settings the project provides.
        /// Note that the package file path 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)
        {
            Guard.ArgumentNotNull(package, "package");
            Guard.ArgumentValid(package.SubPackages.Count == 0, "Package is already expanded", "package");

            string path = package.FullName;

            if (!File.Exists(path))
            {
                return;
            }

            IProject project = LoadFrom(path);

            Guard.ArgumentValid(project != null, "Unable to load project " + path, "package");

            string activeConfig = package.GetSetting(EnginePackageSettings.ActiveConfig, (string)null);

            if (activeConfig == null)
            {
                activeConfig = project.ActiveConfigName;
            }
            else
            {
                Guard.ArgumentValid(project.ConfigNames.Contains(activeConfig), $"Requested configuration {activeConfig} was not found", "package");
            }

            TestPackage tempPackage = project.GetTestPackage(activeConfig);

            // Add info about the configurations to the project package
            tempPackage.Settings[EnginePackageSettings.ActiveConfig] = activeConfig;
            tempPackage.Settings[EnginePackageSettings.ConfigNames]  = project.ConfigNames;

            // The original package held overrides, so don't change them, but
            // do apply any settings specified within the project itself.
            foreach (string key in tempPackage.Settings.Keys)
            {
                if (!package.Settings.ContainsKey(key)) // Don't override settings from command line
                {
                    package.Settings[key] = tempPackage.Settings[key];
                }
            }

            foreach (var subPackage in tempPackage.SubPackages)
            {
                package.AddSubPackage(subPackage);
            }

            // If no config file is specified (by user or by the project loader) check
            // to see if one exists in same directory as the package. If so, we
            // use it. If not, each assembly will use its own config, if present.
            if (!package.Settings.ContainsKey(EnginePackageSettings.ConfigurationFile))
            {
                var packageConfig = Path.ChangeExtension(path, ".config");
                if (File.Exists(packageConfig))
                {
                    package.Settings[EnginePackageSettings.ConfigurationFile] = packageConfig;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Expands a TestPackage based on a known project format, populating it
        /// with the project contents and any settings the project provides.
        /// Note that the package file path 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)
        {
            Guard.ArgumentNotNull(package, "package");
            Guard.ArgumentValid(package.SubPackages.Count == 0, "Package is already expanded", "package");

            string   path    = package.FullName;
            IProject project = LoadFrom(path);

            Guard.ArgumentValid(project != null, "Unable to load project " + path, "package");

            string      configName  = package.GetSetting(PackageSettings.ActiveConfig, (string)null); // Need RunnerSetting
            TestPackage tempPackage = project.GetTestPackage(configName);

            // The original package held overrides, so don't change them, but
            // do apply any settings specified within the project itself.
            foreach (string key in tempPackage.Settings.Keys)
            {
                if (!package.Settings.ContainsKey(key)) // Don't override settings from command line
                {
                    package.Settings[key] = tempPackage.Settings[key];
                }
            }

            foreach (var subPackage in tempPackage.SubPackages)
            {
                package.AddSubPackage(subPackage);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Expands a TestPackage based on a known project format, populating it
        /// with the project contents and any settings the project provides. 
        /// Note that the package file path 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)
        {
            Guard.ArgumentNotNull(package, "package");
            Guard.ArgumentValid(package.SubPackages.Count == 0, "Package is already expanded", "package");

            string path = package.FullName;
            if (!File.Exists(path))
                return;

            IProject project = LoadFrom(path);
            Guard.ArgumentValid(project != null, "Unable to load project " + path, "package");

            string configName = package.GetSetting(EnginePackageSettings.ActiveConfig, (string)null); // Need RunnerSetting
            TestPackage tempPackage = project.GetTestPackage(configName);

            // The original package held overrides, so don't change them, but
            // do apply any settings specified within the project itself.
            foreach (string key in tempPackage.Settings.Keys)
                if (!package.Settings.ContainsKey(key)) // Don't override settings from command line
                    package.Settings[key] = tempPackage.Settings[key];

            foreach (var subPackage in tempPackage.SubPackages)
                package.AddSubPackage(subPackage);

            // If no config is specified (by user or by the proejct loader) check
            // to see if one exists in same directory as the package. If so, we
            // use it. If not, each assembly will use it's own config, if present.
            if (!package.Settings.ContainsKey(EnginePackageSettings.ConfigurationFile))
            {
                var packageConfig = Path.ChangeExtension(path, ".config");
                if (File.Exists(packageConfig))
                    package.Settings[EnginePackageSettings.ConfigurationFile] = packageConfig;
            }
        }
Beispiel #4
0
        public TestPackage GetTestPackage(string configName)
        {
            TestPackage package = new TestPackage(ProjectPath);

            string appbase = null;

            foreach (var name in _configs.Keys)
            {
                if (configName == null || configName == name)
                {
                    var config = _configs[name];
                    package.AddSubPackage(new TestPackage(config.AssemblyPath));
                    appbase = config.OutputDirectory;

                    break;
                }
            }

            if (appbase != null)
            {
                package.AddSetting("BasePath", appbase);
            }

            return(package);
        }
Beispiel #5
0
        public TestPackage GetTestPackage(string configName)
        {
            var package = new TestPackage(ProjectPath);

            if (configName == null)
            {
                configName = ActiveConfigName;
            }

            if (configName != null)
            {
                XmlNode configNode = GetConfigNode(configName);

                string basePath = GetBasePathForConfig(configNode);

                foreach (XmlNode node in configNode.SelectNodes("assembly"))
                {
                    string assembly = node.GetAttribute("path");
                    if (basePath != null)
                    {
                        assembly = Path.Combine(basePath, assembly);
                    }
                    package.AddSubPackage(new TestPackage(assembly));
                }

                var settings = GetSettingsForConfig(configNode);
                foreach (var key in settings.Keys)
                {
                    package.Settings.Add(key, settings[key]);
                }
            }

            return(package);
        }
 void IProjectService.ExpandProjectPackage(TestPackage package)
 {
     if (_projects.ContainsKey(package.Name))
     {
         foreach (string assembly in _projects[package.Name])
         {
             package.AddSubPackage(new TestPackage(assembly));
         }
     }
 }
        public string UseHighestVersionOfSameRuntimeType(params string[] subPackageRuntimes)
        {
            var package = new TestPackage("PACKAGE");

            foreach (string runtime in subPackageRuntimes)
            {
                var subPackage = new TestPackage("SUBPACKAGE");
                if (runtime != "NONE")
                {
                    subPackage.Settings[EnginePackageSettings.ImageTargetFrameworkName] = runtime;
                }
                package.AddSubPackage(subPackage);
            }
            _packageService.UpdatePackage(package);

            return(package.GetSetting(EnginePackageSettings.ImageTargetFrameworkName, "NONE"));
        }
Beispiel #8
0
        public TestPackage GetTestPackage(string configName)
        {
            var package = new TestPackage(ProjectPath);

            foreach (var name in _configs.Keys)
            {
                if (configName == null || configName == name)
                {
                    var config = _configs[name];
                    foreach (string assembly in config.Assemblies)
                    {
                        package.AddSubPackage(new TestPackage(assembly));
                    }
                    break;
                }
            }

            return(package);
        }
Beispiel #9
0
        /// <summary>
        /// Expands a TestPackage based on a known project format, populating it
        /// with the project contents and any settings the project provides. 
        /// Note that the package file path 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)
        {
            Guard.ArgumentNotNull(package, "package");
            Guard.ArgumentValid(package.SubPackages.Count == 0, "Package is already expanded", "package");

            string path = package.FullName;
            IProject project = LoadFrom(path);
            Guard.ArgumentValid(project != null, "Unable to load project " + path, "package");

            string configName = package.GetSetting(PackageSettings.ActiveConfig, (string)null); // Need RunnerSetting
            TestPackage tempPackage = project.GetTestPackage(configName);

            // The original package held overrides, so don't change them, but
            // do apply any settings specified within the project itself.
            foreach (string key in tempPackage.Settings.Keys)
                if (!package.Settings.ContainsKey(key)) // Don't override settings from command line
                    package.Settings[key] = tempPackage.Settings[key];

            foreach (var subPackage in tempPackage.SubPackages)
                package.AddSubPackage(subPackage);
        }
Beispiel #10
0
        public TestPackage GetTestPackage(string configName)
        {
            var package = new TestPackage(ProjectPath);

            foreach (var name in _configs.Keys)
            {
                if (configName == null || configName == name)
                {
                    var config = _configs[name];
                    foreach (string assembly in config.Assemblies)
                    {
                        package.AddSubPackage(new TestPackage(assembly));
                    }
                    break;
                }
            }

            return package;
        }
Beispiel #11
0
        public TestPackage GetTestPackage(string configName)
        {
            TestPackage package = new TestPackage(ProjectPath);

            string appbase = null;
            foreach (var name in _configs.Keys)
            {
                if (configName == null || configName == name)
                {
                    var config = _configs[name];
                    package.AddSubPackage(new TestPackage(config.AssemblyPath));
                    appbase = config.OutputDirectory;
                    break;
                }
            }

            if (appbase != null)
                package.AddSetting("BasePath", appbase);

            return package;
        }
Beispiel #12
0
        public TestPackage GetTestPackage(string configName)
        {
            var package = new TestPackage(ProjectPath);
            if (configName == null)
                configName = ActiveConfigName;

            if (configName != null)
            {
                XmlNode configNode = GetConfigNode(configName);
                
                string basePath = GetBasePathForConfig(configNode);

                foreach (XmlNode node in configNode.SelectNodes("assembly"))
                {
                    string assembly = node.GetAttribute("path");
                    if (basePath != null)
                        assembly = Path.Combine(basePath, assembly);
                    package.AddSubPackage(new TestPackage(assembly));
                }

                var settings = GetSettingsForConfig(configNode);
                foreach (var key in settings.Keys)
                    package.Settings.Add(key, settings[key]);
            }

            return package;
        }