Beispiel #1
0
        /// <summary>
        /// Run the test suite in the given project (dll and project name) with
        /// the configured TestFilterWhere. For the Where syntax, see
        /// NUnit.Engine.TestSelectionParser.ParseFilterElement()
        /// </summary>
        /// <param name="testproject"></param>
        public void Run(string testproject)
        {
            if (HttpContext.Current == null)
            {
                throw new InvalidOperationException("IE tests must run in the w3wp.exe address space");
            }
            // To avoid a cyclic project dependency, the test DLL must be read
            // from an explicit path in the file system, but in .NET Framework,
            // it doesn't need to be formally referenced.
            var approot = HttpContext.Current.Server.MapPath("~");
            var dll     = Path.Combine(approot, @"..\bin", testproject + ".dll");
            var package = new TestPackage(dll);

            // NUnit.EnginePackageSettings
            package.AddSetting("ProcessModel", "Single");
            package.AddSetting("DomainUsage", "None");

            using (var engine = TestEngineActivator.CreateInstance())
                using (var runner = engine.GetRunner(package))
                {
                    var filter = TestFilter.Empty;
                    var where = ConfigurationManager.AppSettings["TestFilterWhere"];
                    if (!String.IsNullOrWhiteSpace(where))
                    {
                        var builder = new TestFilterBuilder();
                        builder.SelectWhere(where);
                        filter = builder.GetFilter(); // returns TestFilter.Empty when no TestFilterWhere is given
                    }
                    TestRunnerBase.Result = runner.Run(this, filter);
                }
        }
Beispiel #2
0
        /// <summary>
        /// Run the test suite in the given project (dll and project name) with
        /// the configured TestFilterWhere. For the path resolution to work,
        /// the test project must be located in the same directory as the
        /// asp.net project. For the Where syntax, see
        /// NUnit.Engine.TestSelectionParser.ParseFilterElement()
        /// </summary>
        /// <param name="testproject"></param>
        public void Run(string testproject)
        {
            // To avoid a cyclic project dependency, the test DLL must be read
            // from an explicit path in the file system, and in .NET Code,
            // it additionally must be formally referenced, therefore the
            // diff / if errorlevel 1 xcopy construct in the post build event
            // to avoid endlessly recompiling a newer, but identical DLL
            // in a cyclic dependency loop.
            var approot = Environment.ContentRootPath;
            var dll     = Path.Combine(approot, @"..\bin", testproject + ".dll");
            var package = new TestPackage(dll); // no TestEngineActivator.CreateInstance() in nunit.engine.netstandard

            // NUnit.EnginePackageSettings
            package.AddSetting("ProcessModel", "Single");
            package.AddSetting("DomainUsage", "None");  // irrelevant in core

            using (var engine = new TestEngine())
                using (var runner = engine.GetRunner(package))
                {
                    var filter = TestFilter.Empty;
                    var where = Configuration["TestFilterWhere"];
                    if (!String.IsNullOrWhiteSpace(where))
                    {
                        var builder = new TestFilterBuilder();
                        builder.SelectWhere(where);
                        filter = builder.GetFilter(); // returns TestFilter.Empty when no TestFilterWhere is given
                    }
                    TestRunnerBase.Result = runner.Run(this, filter);
                }
        }
        public void RequestedFrameworkInvalid()
        {
            _package.AddSetting(EnginePackageSettings.RequestedRuntimeFramework, INVALID_RUNTIME);
            var exception = Assert.Catch <Exception>(() => Validate());

            Assert.That(exception.Message, Is.EqualTo($"The requested framework {INVALID_RUNTIME} is unknown or not available."));
        }
Beispiel #4
0
        /// <see cref="ITestAutomationDiscoverer.DiscoverAutomatedTestsAsync"/>
        public Task <IEnumerable <ITestAutomation> > DiscoverAutomatedTestsAsync(IEnumerable <string> sources)
        {
            var validSources = sources.Where(IsTestAssembly).ToList();

            if (validSources.Count == 0)
            {
                return(Task.FromResult(Enumerable.Empty <ITestAutomation>()));
            }

            var package = new TestPackage(validSources);

            package.AddSetting(PackageSettings.DisposeRunners, true);
            package.AddSetting(PackageSettings.ShadowCopyFiles, true);
            package.AddSetting(PackageSettings.ProcessModel, ProcessModel.Single.ToString());
            package.AddSetting(PackageSettings.DomainUsage, DomainUsage.None.ToString());

            using (var engine = _engineFactory())
                using (var runner = engine.GetRunner(package))
                {
                    var result = runner.Explore(TestFilter.Empty);
                    var xml    = XElement.Load(result.CreateNavigator().ReadSubtree());

                    var tests = (
                        from assembly in xml.DescendantsAndSelf("test-suite")
                        where assembly.Attribute("type").Value == "Assembly"
                        from test in assembly.Descendants("test-case")
                        select new NUnitTestAutomation(test, assembly)).ToList();

                    return(Task.FromResult <IEnumerable <ITestAutomation> >(tests));
                }
        }
Beispiel #5
0
        public void MissingFileTest(string filename, string message)
        {
            var fullname = Path.Combine(TestContext.CurrentContext.TestDirectory, filename);

            var services = new ServiceContext();

            services.Add(new InProcessTestRunnerFactory());
            services.Add(new ExtensionService());
            services.Add(new DriverService());
#if NET35
            services.Add(new RuntimeFrameworkService());
#endif

            var package = new TestPackage(fullname);
            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "None");

            var runner = new MasterTestRunner(services, package);

            var result   = runner.Run(this, TestFilter.Empty);
            var sb       = new StringBuilder();
            var writer   = new ExtendedTextWrapper(new StringWriter(sb));
            var reporter = new ResultReporter(result, writer, new ConsoleOptions());

            reporter.WriteErrorsFailuresAndWarningsReport();
            var report = sb.ToString();

            Assert.That(report, Contains.Substring($"1) Invalid : {fullname}"));
            Assert.That(report, Contains.Substring(message));
        }
Beispiel #6
0
        TDF.TestRunState run(TDF.ITestListener testListener, Assembly testAssembly, string where)
        {
            string      assemblyFile = new Uri(testAssembly.EscapedCodeBase).LocalPath;
            TestPackage package      = new TestPackage(assemblyFile);

            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "None");

            ITestRunner runner = engine.GetRunner(package);

            var filterService          = engine.Services.GetService <ITestFilterService>();
            ITestFilterBuilder builder = filterService.GetTestFilterBuilder();

            if (!string.IsNullOrEmpty(where))
            {
                builder.SelectWhere(where);
            }

            var filter = builder.GetFilter();

            var testRunnerName = getTestRunnerName(testAssembly);
            var eventHandler   = new TestEventListener(testListener, testRunnerName);

            XmlNode result = runner.Run(eventHandler, filter);

            return(eventHandler.TestRunState);
        }
Beispiel #7
0
        public void RuntimeSelection_ProcessModel(string processModel, bool shouldBeAllowed)
        {
            _package.AddSetting(EnginePackageSettings.ImageTargetFrameworkName, "net-4.5");
            _package.AddSetting(EnginePackageSettings.ProcessModel, processModel);
            _model.TestPackage.Returns(_package);

            Assert.That(_controller.AllowRuntimeSelection(), Is.EqualTo(shouldBeAllowed));
        }
Beispiel #8
0
        TestPackage CreatePackage(string path)
        {
            TestPackage package = new TestPackage(path);

            package.AddSetting("ShadowCopyFiles", false);
            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "Single");
            return(package);
        }
Beispiel #9
0
        private static TestPackage CreateTestPackage(IEnumerable <string> testAssemblyFilePaths)
        {
            var testPackage = new TestPackage(testAssemblyFilePaths.ToList());

            testPackage.AddSetting("StopOnError", true);
            testPackage.AddSetting("ShadowCopyFiles", false);
            testPackage.AddSetting("DomainUsage", "Single");
            testPackage.AddSetting("ProcessModel", "Separate");
            return(testPackage);
        }
        /// <summary>
        /// Creates the test package.
        /// </summary>
        /// <param name="assemblies">The list of assemblies.</param>
        /// <returns><see cref="TestPackage"/>.</returns>
        public static TestPackage CreateTestPackage(IList <string> assemblies)
        {
            TestPackage testPackage = new TestPackage(assemblies);

            // TODO Need to convert those hardcoded values to constants
            testPackage.AddSetting("ProcessModel", "Single");
            testPackage.AddSetting("DomainUsage", "None");

            return(testPackage);
        }
Beispiel #11
0
        public void EngineOptionPreferredOverImageTarget(string framework, int majorVersion, int minorVersion, string requested)
        {
            var package = new TestPackage("test");
            package.AddSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, framework);
            package.AddSetting(InternalEnginePackageSettings.ImageRuntimeVersion, new Version(majorVersion, minorVersion));
            package.AddSetting(EnginePackageSettings.RuntimeFramework, requested);

            _runtimeService.SelectRuntimeFramework(package);
            Assert.That(package.GetSetting<string>(EnginePackageSettings.RuntimeFramework, null), Is.EqualTo(requested));
        }
Beispiel #12
0
        public static TestPackage CreatePackage(string path)
        {
            var package = new TestPackage(path);

            package.AddSetting(PackageSettings.ShadowCopyFiles, true);
            package.AddSetting(PackageSettings.ProcessModel, "InProcess");
            package.AddSetting(PackageSettings.DomainUsage, "Single");
            package.AddSetting(PackageSettings.WorkDirectory, Path.GetDirectoryName(path));

            return(package);
        }
Beispiel #13
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 #14
0
        public override async Task RunTestsAsync(CancellationToken token, HashSet <string> tests = null)
        {
            // Get an interface to the engine
            using var engine     = TestEngineActivator.CreateInstance();
            engine.WorkDirectory = new FileInfo(TestProjectAssemblyPath).DirectoryName;

            // Create a simple test package - one assembly, no special settings
            var package = new TestPackage(TestProjectAssemblyPath);

            foreach (var setting in Settings)
            {
                package.AddSetting(setting.Key, setting.Value);
            }

            // Get a runner for the test package
            using var runner = engine.GetRunner(package);

            try
            {
                var run = runner.RunAsync(new NUnitEventListener(this), GetTestFilter(tests));

                await Task.Run(() =>
                {
                    run.Wait(Timeout.Infinite);
                }, token);
            }
            finally
            {
                runner.Dispose();
                engine.Dispose();
            }
        }
Beispiel #15
0
        public static void Main(string[] args)
        {
            var path = Assembly.GetExecutingAssembly().Location;

            var package = new TestPackage(path);

            package.AddSetting("WorkDirectory", Environment.CurrentDirectory);

            using (ITestEngine engine = TestEngineActivator.CreateInstance())
            {
                var filterService = engine.Services.GetService <ITestFilterService>();
                var builder       = filterService.GetTestFilterBuilder();

                var testPlan = getTestPlan();
                if (testPlan != null)
                {
                    foreach (var testCase in testPlan.Tests)
                    {
                        builder.AddTest(testCase.Selector);
                    }
                }

                var filter = builder.GetFilter();
                using (ITestRunner runner = engine.GetRunner(package))
                {
                    runner.Run(listener: null, filter: filter);
                }
            }
        }
 private static void AddAvailableSetting(TestPackage package, bool optionIsSpecified, string name, object value)
 {
     if (optionIsSpecified)
     {
         package.AddSetting(name, value);
     }
 }
Beispiel #17
0
        // Public for testing only
        public TestPackage MakeTestPackage(IList <string> testFiles)
        {
            var package = new TestPackage(testFiles);

            // We use AddSetting rather than just setting the value because
            // it propagates the setting to all subprojects.

            // We use shadow copy so that the user may re-compile while the gui is running.
            package.AddSetting(EnginePackageSettings.ShadowCopyFiles, true);

            foreach (var entry in PackageSettings)
            {
                package.AddSetting(entry.Key, entry.Value);
            }

            return(package);
        }
        public static TestPackage MakeTestPackage(HostedOptions options)
        {
            TestPackage package = new TestPackage(options.InputFiles);

            package.AddSetting(PackageSettings.RuntimeFramework, "v4.0");

            return(package);
        }
Beispiel #19
0
        // Public for testing only
        public TestPackage MakeTestPackage(IList <string> testFiles)
        {
            var package        = new TestPackage(testFiles);
            var engineSettings = Services.UserSettings.Engine;

            // We use AddSetting rather than just setting the value because
            // it propagates the setting to all subprojects.

            if (engineSettings.ProcessModel != "Default")
            {
                package.AddSetting(EnginePackageSettings.ProcessModel, engineSettings.ProcessModel);
            }

            //// Don't set DomainUsage for Multiple to avoid engine error
            //if (engineSettings.ProcessModel != "Multiple")
            //    package.AddSetting(EnginePackageSettings.DomainUsage, engineSettings.DomainUsage);
            //// Don't bother checking Agents unless we are running multiple processes
            //else if (engineSettings.Agents > 0)
            //    package.AddSetting(EnginePackageSettings.MaxAgents, engineSettings.Agents);

            if (engineSettings.SetPrincipalPolicy)
            {
                package.AddSetting(EnginePackageSettings.PrincipalPolicy, engineSettings.PrincipalPolicy);
            }

            //if (Options.InternalTraceLevel != null)
            //    package.AddSetting(EnginePackageSettings.InternalTraceLevel, Options.InternalTraceLevel);

            //package.AddSetting(EnginePackageSettings.ShadowCopyFiles, engineSettings.ShadowCopyFiles);

            foreach (var subpackage in package.SubPackages)
            {
                if (Path.GetExtension(subpackage.Name) == ".sln")
                {
                    subpackage.AddSetting(EnginePackageSettings.SkipNonTestAssemblies, true);
                }
            }

            foreach (var entry in PackageSettings)
            {
                package.AddSetting(entry.Key, entry.Value);
            }

            return(package);
        }
Beispiel #20
0
        /// <summary>
        /// Sets test parameters, handling backwards compatibility.
        /// </summary>
        private static void AddTestParametersSetting(TestPackage testPackage, IDictionary <string, string> testParameters)
        {
            testPackage.AddSetting(FrameworkPackageSettings.TestParametersDictionary, testParameters);

            if (testParameters.Count != 0)
            {
                // This cannot be changed without breaking backwards compatibility with old frameworks.
                // Reserializes the way old frameworks understand, even if this runner's parsing is changed.

                var oldFrameworkSerializedParameters = new StringBuilder();
                foreach (var parameter in testParameters)
                {
                    oldFrameworkSerializedParameters.Append(parameter.Key).Append('=').Append(parameter.Value).Append(';');
                }

                testPackage.AddSetting(FrameworkPackageSettings.TestParameters, oldFrameworkSerializedParameters.ToString(0, oldFrameworkSerializedParameters.Length - 1));
            }
        }
        public void GetAgentsForAssemblySubPackage(string targetRuntime, params string[] expectedAgents)
        {
            // Using the string constructor, which is how a subpackage is created
            var package = new TestPackage("some.dll");

            package.AddSetting(EnginePackageSettings.TargetRuntimeFramework, targetRuntime);

            Assert.That(_testAgency.GetAgentsForPackage(package).Select((info) => info.AgentName),
                        Is.EqualTo(expectedAgents));
        }
Beispiel #22
0
        /// <summary>
        /// Create the nUnit test runner.
        /// </summary>
        public ITestRunner CreateTestRunner(string assemblyPath)
        {
            ITestRunner result = null;
            ITestEngine engine = CreateTestEngine(assemblyPath);

            var         dir         = Path.GetDirectoryName(assemblyPath);
            TestPackage testPackage = new TestPackage(assemblyPath);

            //https://github.com/nunit/nunit-console/blob/master/src/NUnitEngine/nunit.engine/EnginePackageSettings.cs
            string processModel = "InProcess";
            string domainUsage  = "None";

            testPackage.AddSetting(EnginePackageSettings.ProcessModel, processModel);
            testPackage.AddSetting(EnginePackageSettings.DomainUsage, domainUsage);
            testPackage.AddSetting(EnginePackageSettings.WorkDirectory, dir);
            result = engine.GetRunner(testPackage);

            return(result);
        }
Beispiel #23
0
        /// <summary>
        /// Create the nUnit test runner.
        /// </summary>
        private ITestRunner CreateTestRunner()
        {
            ITestRunner result = null;
            ITestEngine engine = CreateTestEngine();

            TestPackage testPackage = new TestPackage(TestAssembly);

            //https://github.com/nunit/nunit-console/blob/master/src/NUnitEngine/nunit.engine/EnginePackageSettings.cs
            string processModel = "InProcess";
            string domainUsage  = "None";

            testPackage.AddSetting(EnginePackageSettings.ProcessModel, processModel);
            testPackage.AddSetting(EnginePackageSettings.DomainUsage, domainUsage);
            result = engine.GetRunner(testPackage);

            var agency = engine.Services.GetService <TestAgency>();

            agency?.StopService();

            return(result);
        }
Beispiel #24
0
        // Public for testing only
        public TestPackage MakeTestPackage(IList <string> testFiles)
        {
            var package        = new TestPackage(testFiles);
            var engineSettings = Services.UserSettings.Engine;

            // We use AddSetting rather than just setting the value because
            // it propagates the setting to all subprojects.

            //WIP: No longer use the process  or domain settings from earlier versions

            if (engineSettings.Agents > 0)
            {
                package.AddSetting(EnginePackageSettings.MaxAgents, engineSettings.Agents);
            }

            if (engineSettings.SetPrincipalPolicy)
            {
                package.AddSetting(EnginePackageSettings.PrincipalPolicy, engineSettings.PrincipalPolicy);
            }

            //if (Options.InternalTraceLevel != null)
            //    package.AddSetting(EnginePackageSettings.InternalTraceLevel, Options.InternalTraceLevel);

            package.AddSetting(EnginePackageSettings.ShadowCopyFiles, engineSettings.ShadowCopyFiles);

            foreach (var subpackage in package.SubPackages)
            {
                if (Path.GetExtension(subpackage.Name) == ".sln")
                {
                    subpackage.AddSetting(EnginePackageSettings.SkipNonTestAssemblies, true);
                }
            }

            foreach (var entry in PackageOverrides)
            {
                package.AddSetting(entry.Key, entry.Value);
            }

            return(package);
        }
Beispiel #25
0
        private ITestRunner CreateTestRunner()
        {
            ITestRunner result = null;

            try {
                mEngine = CreateTestEngine();

                TestPackage testPackage = new TestPackage(TestAssembly);

                //https://github.com/nunit/nunit-console/blob/master/src/NUnitEngine/nunit.engine/EnginePackageSettings.cs
                string processModel = "InProcess";
                string domainUsage  = "None";
                testPackage.AddSetting(EnginePackageSettings.ProcessModel, processModel);
                testPackage.AddSetting(EnginePackageSettings.DomainUsage, domainUsage);
                result = mEngine.GetRunner(testPackage);
            }
            catch (Exception e) {
                MessageBox.Show(e.ToString(), "NUnit Engine", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(result);
        }
Beispiel #26
0
    static void Main(string[] args)
    {
        ITestEngine        engine         = TestEngineActivator.CreateInstance();
        ITestFilterService _filterService = engine.Services.GetService <ITestFilterService>();
        TestPackage        package        = new TestPackage(Assembly.GetExecutingAssembly().Location);

        package.AddSetting("WorkDirectory", Environment.CurrentDirectory);
        using (ITestRunner runner = engine.GetRunner(package))
        {
            ITestFilterBuilder builder = _filterService.GetTestFilterBuilder();
            XmlNode            result  = runner.Run(null, builder.GetFilter());
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            // set up the options
            string      path    = Assembly.GetExecutingAssembly().Location;
            TestPackage package = new TestPackage(path);

            package.AddSetting("ProcessModel", "Single");
            package.AddSetting("DomainUsage", "None");

            // prepare the engine
            ITestEngine        engine         = TestEngineActivator.CreateInstance();
            var                _filterService = engine.Services.GetService <ITestFilterService>();
            ITestFilterBuilder builder        = _filterService.GetTestFilterBuilder();
            TestFilter         emptyFilter    = builder.GetFilter();

            using (ITestRunner runner = engine.GetRunner(package))
            {
                // execute the tests
                XmlNode result = runner.Run(null, emptyFilter);
                lblTest.Text = result.InnerText;
            }
        }
Beispiel #28
0
        public void CorrectRunnerIsUsed(string files, string processModel, Type expectedType)
        {
            var package = new TestPackage(files.Split(new char[] { ' ' }));

            if (processModel != null)
            {
                package.AddSetting("ProcessModel", processModel);
            }

            var runner = _factory.MakeTestRunner(package);

            Assert.That(runner, Is.TypeOf(expectedType));
        }
Beispiel #29
0
        public void RequestedFrameworkInvalid()
        {
            _package.AddSetting(EnginePackageSettings.RequestedRuntimeFramework, INVALID_RUNTIME);

            var exception = Assert.Throws <NUnitEngineException>(() => Validate());

            CheckMessageContent(exception.Message, $"The requested framework {INVALID_RUNTIME} is unknown or not available.");
        }
        public void CorrectRunnerIsUsed(string files, string processModel, Type expectedType)
        {
            if (files == "EngineTests.nunit")
            {
                files = Path.Combine(TestContext.CurrentContext.TestDirectory, files);
            }

            var package = new TestPackage(files.Split(new char[] { ' ' }));

            if (processModel != null)
            {
                package.AddSetting("ProcessModel", processModel);
            }

            var runner = _factory.MakeTestRunner(package);

            Assert.That(runner, Is.TypeOf(expectedType));
        }
Beispiel #31
0
        // This is public static for ease of testing
        public static TestPackage MakeTestPackage(ConsoleOptions options)
        {
            TestPackage package = new TestPackage(options.InputFiles);

            if (options.ProcessModelSpecified)
                package.AddSetting(PackageSettings.ProcessModel, options.ProcessModel);

            if (options.DomainUsageSpecified)
                package.AddSetting(PackageSettings.DomainUsage, options.DomainUsage);

            if (options.FrameworkSpecified)
                package.AddSetting(PackageSettings.RuntimeFramework, options.Framework);

            if (options.RunAsX86)
                package.AddSetting(PackageSettings.RunAsX86, true);

            if (options.DisposeRunners)
                package.AddSetting(PackageSettings.DisposeRunners, true);

            if (options.ShadowCopyFiles)
                package.AddSetting(PackageSettings.ShadowCopyFiles, true);

            if (options.DefaultTimeout >= 0)
                package.AddSetting(PackageSettings.DefaultTimeout, options.DefaultTimeout);

            if (options.InternalTraceLevelSpecified)
                package.AddSetting(PackageSettings.InternalTraceLevel, options.InternalTraceLevel);

            if (options.ActiveConfigSpecified)
                package.AddSetting(PackageSettings.ActiveConfig, options.ActiveConfig);

            // Always add work directory, in case current directory is changed
            var workDirectory = options.WorkDirectory ?? Environment.CurrentDirectory;
            package.AddSetting(PackageSettings.WorkDirectory, workDirectory);

            if (options.StopOnError)
                package.AddSetting(PackageSettings.StopOnError, true);

            if (options.MaxAgentsSpecified)
                package.AddSetting(PackageSettings.MaxAgents, options.MaxAgents);

            if (options.NumberOfTestWorkersSpecified)
                package.AddSetting(PackageSettings.NumberOfTestWorkers, options.NumberOfTestWorkers);

            if (options.RandomSeedSpecified)
                package.AddSetting(PackageSettings.RandomSeed, options.RandomSeed);

            if (options.DebugTests)
            {
                package.AddSetting(PackageSettings.DebugTests, true);

                if (!options.NumberOfTestWorkersSpecified)
                    package.AddSetting(PackageSettings.NumberOfTestWorkers, 0);
            }

            if (options.PauseBeforeRun)
                package.AddSetting(PackageSettings.PauseBeforeRun, true);

#if DEBUG
            if (options.DebugAgent)
                package.AddSetting(PackageSettings.DebugAgent, true);

            //foreach (KeyValuePair<string, object> entry in package.Settings)
            //    if (!(entry.Value is string || entry.Value is int || entry.Value is bool))
            //        throw new Exception(string.Format("Package setting {0} is not a valid type", entry.Key));
#endif

            return package;
        }
Beispiel #32
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 #33
0
        // This is public static for ease of testing
        public static TestPackage MakeTestPackage(ConsoleOptions options)
        {
            TestPackage package = new TestPackage(options.InputFiles);

            if (options.ProcessModel != null) //ProcessModel.Default)
                package.AddSetting(PackageSettings.ProcessModel, options.ProcessModel);

            if (options.DomainUsage != null)
                package.AddSetting(PackageSettings.DomainUsage, options.DomainUsage);

            if (options.Framework != null)
                package.AddSetting(PackageSettings.RuntimeFramework, options.Framework);

            if (options.RunAsX86)
                package.AddSetting(PackageSettings.RunAsX86, true);

            if (options.DisposeRunners)
                package.AddSetting(PackageSettings.DisposeRunners, true);

            if (options.ShadowCopyFiles)
                package.AddSetting(PackageSettings.ShadowCopyFiles, true);

            if (options.DefaultTimeout >= 0)
                package.AddSetting(PackageSettings.DefaultTimeout, options.DefaultTimeout);

            if (options.InternalTraceLevel != null)
                package.AddSetting(PackageSettings.InternalTraceLevel, options.InternalTraceLevel);

            if (options.ActiveConfig != null)
                package.AddSetting(PackageSettings.ActiveConfig, options.ActiveConfig);

            if (options.WorkDirectory != null)
                package.AddSetting(PackageSettings.WorkDirectory, options.WorkDirectory);

            if (options.StopOnError)
                package.AddSetting(PackageSettings.StopOnError, true);

            if (options.NumWorkers >= 0)
                package.AddSetting(PackageSettings.NumberOfTestWorkers, options.NumWorkers);

            if (options.RandomSeed > 0)
                package.AddSetting(PackageSettings.RandomSeed, options.RandomSeed);

            if (options.Verbose)
                package.AddSetting("Verbose", true);

#if DEBUG
            //foreach (KeyValuePair<string, object> entry in package.Settings)
            //    if (!(entry.Value is string || entry.Value is int || entry.Value is bool))
            //        throw new Exception(string.Format("Package setting {0} is not a valid type", entry.Key));
#endif

            return package;
        }
        public static TestPackage MakeTestPackage(HostedOptions options)
        {
            TestPackage package = new TestPackage(options.InputFiles);
            package.AddSetting(PackageSettings.RuntimeFramework, "v4.0");

            return package;
        }
        public void CorrectRunnerIsUsed(string files, string processModel, Type expectedType)
        {
            var package = new TestPackage(files.Split(new char[] { ' ' }));
            if (processModel != null)
                package.AddSetting("ProcessModel", processModel);

            var runner = _factory.MakeTestRunner(package);

            Assert.That(runner, Is.TypeOf(expectedType));
        }
        public void CorrectRunnerIsUsed(string files, string processModel, Type expectedType)
        {
            var package = new TestPackage(files.Split(new char[] { ' ' }));
            if (processModel != null)
                package.AddSetting("ProcessModel", processModel);

            var runner = _factory.MakeTestRunner(package);

            Assert.That(runner, Is.TypeOf(expectedType));

            var aggRunner = runner as AggregatingTestRunner;
            if (aggRunner != null)
                foreach (var childRunner in aggRunner.Runners)
                    Assert.That(childRunner, Is.TypeOf<TestDomainRunner>());
        }
		TestPackage CreatePackage (string path)
		{
			TestPackage package = new TestPackage (path);
			package.AddSetting ("ShadowCopyFiles", false);
			package.AddSetting ("ProcessModel", "InProcess");
			package.AddSetting ("DomainUsage", "Single");
			return package;
		}