当前位置: 首页>>代码示例>>C#>>正文


C# TestPackage.GetSetting方法代码示例

本文整理汇总了C#中TestPackage.GetSetting方法的典型用法代码示例。如果您正苦于以下问题:C# TestPackage.GetSetting方法的具体用法?C# TestPackage.GetSetting怎么用?C# TestPackage.GetSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestPackage的用法示例。


在下文中一共展示了TestPackage.GetSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectRuntimeFramework

        public void SelectRuntimeFramework(string assemblyName, string expectedVersion, bool runAsX86)
        {
            // Some files don't actually exist on our CI servers
            Assume.That(assemblyName, Does.Exist);
            var package = new TestPackage(assemblyName);

            var returnValue = _runtimeService.SelectRuntimeFramework(package);
            var framework = RuntimeFramework.Parse(returnValue);

            Assert.That(package.GetSetting("RuntimeFramework", ""), Is.EqualTo(returnValue));
            Assert.That(package.GetSetting("RunAsX86", false), Is.EqualTo(runAsX86));
            Assert.That(framework.ClrVersion.ToString(), Is.EqualTo(expectedVersion));
        }
开发者ID:alfeg,项目名称:nunit,代码行数:13,代码来源:RuntimeFrameworkServiceTests.cs

示例2: MakeTestRunner

        /// <summary>
        /// Returns a test runner based on the settings in a TestPackage.
        /// Any setting that is "consumed" by the factory is removed, so
        /// that downstream runners using the factory will not repeatedly
        /// create the same type of runner.
        /// </summary>
        /// <param name="package">The TestPackage to be loaded and run</param>
        /// <returns>An ITestEngineRunner</returns>
        public virtual ITestEngineRunner MakeTestRunner(TestPackage package)
        {
            DomainUsage domainUsage = (DomainUsage)System.Enum.Parse(
                typeof(DomainUsage),
                package.GetSetting(EnginePackageSettings.DomainUsage, "Default"));

            switch (domainUsage)
            {
                default:
                case DomainUsage.Default:
                    if (package.SubPackages.Count > 1)
                        return new MultipleTestDomainRunner(this.ServiceContext, package);
                    else
                        return new TestDomainRunner(this.ServiceContext, package);

                case DomainUsage.Multiple:
                    return new MultipleTestDomainRunner(ServiceContext, package);

                case DomainUsage.None:
                    return new LocalTestRunner(ServiceContext, package);

                case DomainUsage.Single:
                    return new TestDomainRunner(ServiceContext, package);
            }
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:33,代码来源:InProcessTestRunnerFactory.cs

示例3: ExpandProjectPackage

        /// <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;
            }
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:41,代码来源:ProjectService.cs

示例4: MakeTestRunner

        /// <summary>
        /// Returns a test runner based on the settings in a TestPackage.
        /// Any setting that is "consumed" by the factory is removed, so
        /// that downstream runners using the factory will not repeatedly
        /// create the same type of runner.
        /// </summary>
        /// <param name="package">The TestPackage to be loaded and run</param>
        /// <returns>An ITestEngineRunner</returns>
        public virtual ITestEngineRunner MakeTestRunner(TestPackage package)
        {
            switch (package.GetSetting(PackageSettings.DomainUsage, "Default"))
            {
                case "None":
                    return new LocalTestRunner(ServiceContext, package);

                default:
                case "Single":
                    return new TestDomainRunner(ServiceContext, package);
            }
        }
开发者ID:JohanLarsson,项目名称:nunit,代码行数:20,代码来源:CoreTestRunnerFactory.cs

示例5: SelectRuntimeFramework

        /// <summary>
        /// Selects a target runtime framework for a TestPackage based on
        /// the settings in the package and the assemblies themselves.
        /// The package RuntimeFramework setting may be updated as a 
        /// result and the selected runtime is returned.
        /// </summary>
        /// <param name="package">A TestPackage</param>
        /// <returns>The selected RuntimeFramework</returns>
        public RuntimeFramework SelectRuntimeFramework(TestPackage package)
        {
            RuntimeFramework currentFramework = RuntimeFramework.CurrentFramework;
            string frameworkSetting = package.GetSetting(RunnerSettings.RuntimeFramework, "");
            RuntimeFramework requestedFramework = frameworkSetting.Length > 0
                ? RuntimeFramework.Parse(frameworkSetting)
                : new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion);

            log.Debug("Current framework is {0}", currentFramework);
            if (requestedFramework == null)
                log.Debug("No specific framework requested");
            else
                log.Debug("Requested framework is {0}", requestedFramework);

            RuntimeType targetRuntime = requestedFramework.Runtime;
            Version targetVersion = requestedFramework.FrameworkVersion;

            if (targetRuntime == RuntimeType.Any)
                targetRuntime = currentFramework.Runtime;

            if (targetVersion == RuntimeFramework.DefaultVersion)
            {
                if (ServiceContext.UserSettings.GetSetting("Options.TestLoader.RuntimeSelectionEnabled", true))
                    foreach (string assembly in package.TestFiles)
                    {
                        using (AssemblyReader reader = new AssemblyReader(assembly))
                        {
                            Version v = new Version(reader.ImageRuntimeVersion.Substring(1));
                            log.Debug("Assembly {0} uses version {1}", assembly, v);
                            if (v > targetVersion) targetVersion = v;
                        }
                    }
                else
                    targetVersion = RuntimeFramework.CurrentFramework.ClrVersion;

                RuntimeFramework checkFramework = new RuntimeFramework(targetRuntime, targetVersion);
                if (!checkFramework.IsAvailable || !ServiceContext.TestAgency.IsRuntimeVersionSupported(targetVersion))
                {
                    log.Debug("Preferred version {0} is not installed or this NUnit installation does not support it", targetVersion);
                    if (targetVersion < currentFramework.FrameworkVersion)
                        targetVersion = currentFramework.FrameworkVersion;
                }
            }

            RuntimeFramework targetFramework = new RuntimeFramework(targetRuntime, targetVersion);
            package.Settings[RunnerSettings.RuntimeFramework] = targetFramework.ToString();

            log.Debug("Test will use {0} framework", targetFramework);

            return targetFramework;
        }
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:59,代码来源:RuntimeFrameworkSelector.cs

示例6: MakeTestRunner

        /// <summary>
        /// Returns a test runner based on the settings in a TestPackage.
        /// Any setting that is "consumed" by the factory is removed, so
        /// that downstream runners using the factory will not repeatedly
        /// create the same type of runner.
        /// </summary>
        /// <param name="package">The TestPackage to be loaded and run</param>
        /// <returns>An ITestEngineRunner</returns>
        public virtual ITestEngineRunner MakeTestRunner(TestPackage package)
        {
            DomainUsage domainUsage = (DomainUsage)System.Enum.Parse(
                typeof(DomainUsage),
                package.GetSetting(RunnerSettings.DomainUsage, "Default"));

            switch (domainUsage)
            {
                case DomainUsage.Multiple:
                    package.Settings.Remove("DomainUsage");
                    return new MultipleTestDomainRunner(ServiceContext, package);
                case DomainUsage.None:
                    return new LocalTestRunner(ServiceContext, package);
                case DomainUsage.Single:
                default:
                    return new TestDomainRunner(ServiceContext, package);
            }
        }
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:26,代码来源:InProcessTestRunnerFactory.cs

示例7: ExpandProjectPackage

        /// <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);
        }
开发者ID:rojac07,项目名称:nunit,代码行数:28,代码来源:ProjectService.cs

示例8: CanReuse

        public override bool CanReuse(ITestEngineRunner runner, TestPackage package)
        {
            RuntimeFramework currentFramework = RuntimeFramework.CurrentFramework;
            RuntimeFramework targetFramework = ServiceContext.RuntimeFrameworkSelector.SelectRuntimeFramework(package);

            ProcessModel processModel = (ProcessModel)System.Enum.Parse(
                typeof(ProcessModel),
                package.GetSetting(RunnerSettings.ProcessModel, "Default"));
            if (processModel == ProcessModel.Default)
                if (!currentFramework.Supports(targetFramework))
                    processModel = ProcessModel.Separate;

            switch (processModel)
            {
                case ProcessModel.Multiple:
                    return runner is MultipleTestProcessRunner;
                case ProcessModel.Separate:
                    ProcessRunner processRunner = runner as ProcessRunner;
                    return processRunner != null && processRunner.RuntimeFramework == targetFramework;
                default:
                    return base.CanReuse(runner, package);
            }
        }
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:23,代码来源:DefaultTestRunnerFactory.cs

示例9: GetTargetProcessModel

 private ProcessModel GetTargetProcessModel(TestPackage package)
 {
     return (ProcessModel)System.Enum.Parse(
         typeof(ProcessModel),
         package.GetSetting(EnginePackageSettings.ProcessModel, "Default"));
 }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:6,代码来源:DefaultTestRunnerFactory.cs

示例10: CreateAppDomainSetup

        // Made separate and internal for testing
        AppDomainSetup CreateAppDomainSetup(TestPackage package)
        {
            AppDomainSetup setup = new AppDomainSetup();

            if (package.SubPackages.Count == 1)
                package = package.SubPackages[0];

            //For parallel tests, we need to use distinct application name
            setup.ApplicationName = "Tests" + "_" + Environment.TickCount;

            string appBase = GetApplicationBase(package);
            setup.ApplicationBase = appBase;
            setup.ConfigurationFile = GetConfigFile(appBase, package);
            setup.PrivateBinPath = GetPrivateBinPath(appBase, package); 

            if (!string.IsNullOrEmpty(package.FullName))
            {
                // Setting the target framework is only supported when running with
                // multiple AppDomains, one per assembly.
                SetTargetFramework(package.FullName, setup);
            }

            if (package.GetSetting("ShadowCopyFiles", false))
            {
                setup.ShadowCopyFiles = "true";
                setup.ShadowCopyDirectories = setup.ApplicationBase;
                setup.CachePath = GetCachePath();
            }
            else
                setup.ShadowCopyFiles = "false";

            return setup;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:34,代码来源:DomainManager.cs

示例11: GetPrivateBinPath

        public static string GetPrivateBinPath(string appBase, TestPackage package)
        {
            var binPath = package.GetSetting(PackageSettings.PrivateBinPath, string.Empty);

            if (package.GetSetting(PackageSettings.AutoBinPath, binPath == string.Empty))
                binPath = package.SubPackages.Count > 0
                    ? GetPrivateBinPath(appBase, package.SubPackages)
                    : package.FullName != null
                        ? GetPrivateBinPath(appBase, package.FullName)
                        : null;

            return binPath;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:13,代码来源:DomainManager.cs

示例12: GetConfigFile

        public static string GetConfigFile(string appBase, TestPackage package)
        {
            Guard.ArgumentNotNullOrEmpty(appBase, "appBase");
            Guard.ArgumentNotNull(package, "package");

            // Use provided setting if available
            string configFile = package.GetSetting(PackageSettings.ConfigurationFile, string.Empty);
            if (configFile != string.Empty)
                return Path.Combine(appBase, configFile);
        
            // The ProjectService adds any project config to the settings.
            // So, at this point, we only want to handle assemblies or an
            // anonymous package created from the comnand-line.
            string fullName = package.FullName;
            if (IsExecutable(fullName))
                return fullName + ".config";

            // Command-line package gets no config unless it's a single assembly
            if (string.IsNullOrEmpty(fullName) && package.SubPackages.Count == 1)
            {
                fullName = package.SubPackages[0].FullName;
                if (IsExecutable(fullName))
                    return fullName + ".config";
            }

            // No config file will be specified
            return null;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:28,代码来源:DomainManager.cs

示例13: GetApplicationBase

        /// <summary>
        /// Figure out the ApplicationBase for a package
        /// </summary>
        /// <param name="package">The package</param>
        /// <returns>The ApplicationBase</returns>
        public static string GetApplicationBase(TestPackage package)
        {
            Guard.ArgumentNotNull(package, "package");

            var appBase = package.GetSetting(PackageSettings.BasePath, string.Empty);

            if (string.IsNullOrEmpty(appBase))
                appBase = string.IsNullOrEmpty(package.FullName)
                    ? GetCommonAppBase(package.SubPackages)
                    : Path.GetDirectoryName(package.FullName);

            if (!string.IsNullOrEmpty(appBase))
            {
                char lastChar = appBase[appBase.Length - 1];
                if (lastChar != Path.DirectorySeparatorChar && lastChar != Path.AltDirectorySeparatorChar)
                    appBase += Path.DirectorySeparatorChar;
            }

            return appBase;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:25,代码来源:DomainManager.cs

示例14: CreateAppDomainSetup

        // Made separate and internal for testing
        AppDomainSetup CreateAppDomainSetup(TestPackage package)
        {
            AppDomainSetup setup = new AppDomainSetup();

            if (package.SubPackages.Count == 1)
                package = package.SubPackages[0];

            //For parallel tests, we need to use distinct application name
            setup.ApplicationName = "Tests" + "_" + Environment.TickCount;

            string appBase = GetApplicationBase(package);
            setup.ApplicationBase = appBase;
            setup.ConfigurationFile = GetConfigFile(appBase, package);
            setup.PrivateBinPath = GetPrivateBinPath(appBase, package); 

            if (!string.IsNullOrEmpty(package.FullName))
            {
                // Setting the target framework is only supported when running with
                // multiple AppDomains, one per assembly.
                // TODO: Remove this limitation

                // .NET versions greater than v4.0 report as v4.0, so look at
                // the TargetFrameworkAttribute on the assembly if it exists
                // If property is null, .NET 4.5+ is not installed, so there is no need
                if (TargetFrameworkNameProperty != null)
                {
                    var frameworkName = package.GetSetting(PackageSettings.ImageTargetFrameworkName, "");
                    if (frameworkName != "")
                        TargetFrameworkNameProperty.SetValue(setup, frameworkName, null);
                }
            }

            if (package.GetSetting("ShadowCopyFiles", false))
            {
                setup.ShadowCopyFiles = "true";
                setup.ShadowCopyDirectories = setup.ApplicationBase;
            }
            else
                setup.ShadowCopyFiles = "false";

            return setup;
        }
开发者ID:acco32,项目名称:nunit,代码行数:43,代码来源:DomainManager.cs

示例15: ExpandProjectPackage

        /// <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);
        }
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:22,代码来源:ProjectService.cs


注:本文中的TestPackage.GetSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。