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));
            }
        }
        public void UnspecifiedVersion_SameRuntime_Supported(RuntimeFramework f1)
        {
            RuntimeFramework f2 = new RuntimeFramework(f1.Runtime, RuntimeFramework.DefaultVersion);

            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
        public void DifferentRuntimes_NotSupported(RuntimeFramework f1)
        {
            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Net, f1.FrameworkVersion);

            Assert.False(f1.Supports(f2));
            Assert.False(f2.Supports(f1));
        }
        public void UnspecifiedRuntimeAndVersion_Supported(RuntimeFramework f1)
        {
            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion);

            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
        public override bool CanReuse(TestRunner runner, TestPackage package)
        {
            RuntimeFramework currentFramework = RuntimeFramework.CurrentFramework;
            RuntimeFramework targetFramework  = selector.SelectRuntimeFramework(package);

            ProcessModel processModel = (ProcessModel)package.GetSetting("ProcessModel", 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));
            }
        }
        public void SameRuntimes_DifferentBuilds_NotSupported()
        {
            RuntimeFramework f1 = new RuntimeFramework(RuntimeType.Net, new Version(2, 0, 50727));
            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Net, new Version(2, 0, 40607));

            Assert.False(f1.Supports(f2));
            Assert.False(f2.Supports(f1));
        }
        public void UnspecifiedRuntime_SameVersion_Supported(RuntimeFramework f1)
        {
            // NOTE: Mono 1.0 has a 1.1 ClrVersion, so this doesn't work.
            // Since we're phasing out support for 1.x versions, we
            // aren't planning to fix this.
            Assume.That(f1.ToString() != "mono-1.0");

            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Any, f1.FrameworkVersion);

            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
        public void WellKnownClrVersions_SupportEquivalentFrameworkVersions(string s)
        {
            RuntimeFramework f1 = RuntimeFramework.Parse(s);
            RuntimeFramework f2 = new RuntimeFramework(f1.Runtime, f1.FrameworkVersion);

            Assert.That(f1.Runtime, Is.EqualTo(f2.Runtime));
            Assert.That(f1.FrameworkVersion, Is.EqualTo(f2.FrameworkVersion));
            Assert.That(f1.ClrVersion, Is.EqualTo(f2.ClrVersion));

            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
        public void Mono11IsSynonymousWithMono10()
        {
            RuntimeFramework mono10 = new RuntimeFramework(RuntimeType.Mono, new Version(1, 0));
            RuntimeFramework mono11 = new RuntimeFramework(RuntimeType.Mono, new Version(1, 1));

            Assert.That(mono11.ToString(), Is.EqualTo("mono-1.0"));
            Assert.That(mono11.DisplayName, Is.EqualTo("Mono 1.0"));
            Assert.That(mono11.Runtime, Is.EqualTo(RuntimeType.Mono));
            Assert.That(mono11.FrameworkVersion, Is.EqualTo(new Version(1, 0)));

            Assert.That(mono11.Supports(mono10));
            Assert.That(mono10.Supports(mono11));
        }
        private ProcessModel GetTargetProcessModel(TestPackage package)
        {
            RuntimeFramework currentFramework = RuntimeFramework.CurrentFramework;
            RuntimeFramework targetFramework  = selector.SelectRuntimeFramework(package);

            ProcessModel processModel = (ProcessModel)package.GetSetting("ProcessModel", ProcessModel.Default);

            if (processModel == ProcessModel.Default)
            {
                if (!currentFramework.Supports(targetFramework))
                {
                    processModel = ProcessModel.Separate;
                }
            }
            return(processModel);
        }
        private ProcessModel GetTargetProcessModel(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;
                }
            }

            return(processModel);
        }
        private RuntimeFramework SelectRuntimeFrameworkInner(TestPackage package)
        {
            foreach (var subPackage in package.SubPackages)
            {
                SelectRuntimeFrameworkInner(subPackage);
            }

            // Examine the provided settings
            RuntimeFramework currentFramework = RuntimeFramework.CurrentFramework;

            log.Debug("Current framework is " + currentFramework);

            string requestedFrameworkSetting = package.GetSetting(EnginePackageSettings.RuntimeFramework, "");

            if (requestedFrameworkSetting.Length > 0)
            {
                RuntimeFramework requestedFramework;
                if (!RuntimeFramework.TryParse(requestedFrameworkSetting, out requestedFramework))
                {
                    throw new NUnitEngineException("Invalid or unknown framework requested: " + requestedFrameworkSetting);
                }

                log.Debug($"Requested framework for {package.Name} is {requestedFramework}");

                if (!IsAvailable(requestedFramework))
                {
                    throw new NUnitEngineException("Requested framework is not available: " + requestedFrameworkSetting);
                }

                return(requestedFramework);
            }

            log.Debug($"No specific framework requested for {package.Name}");

            string imageTargetFrameworkNameSetting = package.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, "");

            RuntimeFramework targetFramework;

            // HACK: handling the TargetFrameworkName does not currently work outside of windows
            if (Environment.OSVersion.Platform == PlatformID.Win32NT && imageTargetFrameworkNameSetting.Length > 0)
            {
                targetFramework = RuntimeFramework.FromFrameworkName(imageTargetFrameworkNameSetting);

                // TODO: temporary exception thrown until we implement .NET Core
                if (targetFramework.Runtime == Runtime.NetCore)
                {
                    throw new NotImplementedException("The GUI does not yet support .NET Core tests");
                }
            }
            else
            {
                var targetVersion = package.GetSetting(InternalEnginePackageSettings.ImageRuntimeVersion, currentFramework.FrameworkVersion);
                targetFramework = new RuntimeFramework(currentFramework.Runtime, targetVersion);
            }

            if (!IsAvailable(targetFramework))
            {
                log.Debug("Preferred target framework {0} is not available.", targetFramework);
                if (currentFramework.Supports(targetFramework))
                {
                    targetFramework = currentFramework;
                    log.Debug($"Using {currentFramework}");
                }
            }

            package.Settings[EnginePackageSettings.RuntimeFramework] = targetFramework.ToString();

            log.Debug($"Test will use {targetFramework} for {package.Name}");
            return(targetFramework);
        }
Example #13
0
 public void SameRuntime_LowerVersion_SameCLR_Supported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.That(f1.Supports(f2));
 }
Example #14
0
 public void SameRuntime_HigherVersion_NotSupported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.False(f1.Supports(f2));
 }
Example #15
0
 public bool CanMatchRuntimes(RuntimeFramework f1, RuntimeFramework f2)
 {
     return(f1.Supports(f2));
 }
 public bool CanMatchRuntimes(RuntimeFramework f1, RuntimeFramework f2)
 {
     return f1.Supports(f2);
 }
Example #17
0
        public void DifferentRuntimes_NotSupported(RuntimeFramework f1)
        {
            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Net, f1.FrameworkVersion);

            Assert.False(f1.Supports(f2));
            Assert.False(f2.Supports(f1));
        }
Example #18
0
 public void SameRuntime_LowerVersion_DifferentCLR_NotSupported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.False(f1.Supports(f2));
 }
Example #19
0
        public void UnspecifiedRuntime_SameVersion_Supported(RuntimeFramework f1)
        {
            // NOTE: Mono 1.0 has a 1.1 ClrVersion, so this doesn't work.
            // Since we're phasing out support for 1.x versions, we
            // aren't planning to fix this.
            Assume.That(f1.ToString() != "mono-1.0");

            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Any, f1.FrameworkVersion);
            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
Example #20
0
        public void SameRuntimes_DifferentBuilds_NotSupported()
        {
            RuntimeFramework f1 = new RuntimeFramework(RuntimeType.Net, new Version(2, 0, 50727));
            RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Net, new Version(2, 0, 40607));

            Assert.False(f1.Supports(f2));
            Assert.False(f2.Supports(f1));
        }
Example #21
0
 public void SameRuntime_LowerVersion_DifferentCLR_NotSupported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.False(f1.Supports(f2));
 }
Example #22
0
 public void UnspecifiedVersion_SameRuntime_Supported(RuntimeFramework f1)
 {
     RuntimeFramework f2 = new RuntimeFramework(f1.Runtime, RuntimeFramework.DefaultVersion);
     Assert.That(f1.Supports(f2));
     Assert.That(f2.Supports(f1));
 }
Example #23
0
 public void SameRuntime_LowerVersion_SameCLR_Supported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.That(f1.Supports(f2));
 }
Example #24
0
        public void WellKnownClrVersions_SupportEquivalentFrameworkVersions(string s)
        {
            RuntimeFramework f1 = RuntimeFramework.Parse(s);
            RuntimeFramework f2 = new RuntimeFramework(f1.Runtime, f1.FrameworkVersion);

            Assert.That(f1.Runtime, Is.EqualTo(f2.Runtime));
            Assert.That(f1.FrameworkVersion, Is.EqualTo(f2.FrameworkVersion));
            Assert.That(f1.ClrVersion, Is.EqualTo(f2.ClrVersion));

            Assert.That(f1.Supports(f2));
            Assert.That(f2.Supports(f1));
        }
Example #25
0
 public void UnspecifiedRuntimeAndVersion_Supported(RuntimeFramework f1)
 {
     RuntimeFramework f2 = new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion);
     Assert.That(f1.Supports(f2));
     Assert.That(f2.Supports(f1));
 }
Example #26
0
 public void AnyFrameworkSupportsItself(RuntimeFramework framework)
 {
     Assert.That(framework.Supports(framework));
 }
Example #27
0
 public void AnyFrameworkSupportsItself(RuntimeFramework framework)
 {
     Assert.That(framework.Supports(framework));
 }
Example #28
0
 public void SameRuntime_HigherVersion_NotSupported(RuntimeFramework f1, RuntimeFramework f2)
 {
     Assert.False(f1.Supports(f2));
 }
Example #29
0
        public void Mono11IsSynonymousWithMono10()
        {
            RuntimeFramework mono10 = new RuntimeFramework(RuntimeType.Mono, new Version(1, 0));
            RuntimeFramework mono11 = new RuntimeFramework(RuntimeType.Mono, new Version(1, 1));

            Assert.That(mono11.ToString(), Is.EqualTo("mono-1.0"));
            Assert.That(mono11.DisplayName, Is.EqualTo("Mono 1.0"));
            Assert.That(mono11.Runtime, Is.EqualTo(RuntimeType.Mono));
            Assert.That(mono11.FrameworkVersion, Is.EqualTo(new Version(1, 0)));

            Assert.That(mono11.Supports(mono10));
            Assert.That(mono10.Supports(mono11));
        }