Ejemplo n.º 1
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
            }

            if ((platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
                (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
                (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
                (platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
                (platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)))
            {
                if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.UapNotUapAot))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.UapAot))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapAotTest));
                }
                if (frameworks == (TargetFrameworkMonikers)0)
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
                }

                yield return(new KeyValuePair <string, string>(XunitConstants.ActiveIssue, issue));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            IEnumerable <object> ctorArgs = traitAttribute.GetConstructorArguments();

            Debug.Assert(ctorArgs.Count() >= 2);

            string                  issue      = ctorArgs.First().ToString();
            TestPlatforms           platforms  = TestPlatforms.Any;
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;

            foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
            {
                if (arg is TestPlatforms)
                {
                    platforms = (TestPlatforms)arg;
                }
                else if (arg is TargetFrameworkMonikers)
                {
                    frameworks = (TargetFrameworkMonikers)arg;
                }
            }

            if (DiscovererHelpers.TestPlatformApplies(platforms))
            {
                if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
                }
                if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
                }
                if (frameworks == (TargetFrameworkMonikers)0)
                {
                    yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing));
                }

                yield return(new KeyValuePair <string, string>(XunitConstants.ActiveIssue, issue));
            }
        }
Ejemplo n.º 4
0
        (runtimes.HasFlag(TestRuntimes.CoreCLR) && !IsMonoRuntime);         // assume CoreCLR if it's not Mono

        public static bool TestFrameworkApplies(TargetFrameworkMonikers frameworks) =>
        (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp) && IsRunningOnNetCoreApp) ||
        (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework) && IsRunningOnNetFramework);
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (frameworks.HasFlag(TargetFrameworkMonikers.Net45))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet45Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net451))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet451Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net452))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet452Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net46))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet46Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net461))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet461Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net462))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet462Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Net463))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet463Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcore50))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcore50aot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonMonoTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.UapNotUapAot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.UapAot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonUapAotTest));
            }
            if (frameworks.HasFlag(TargetFrameworkMonikers.NetcoreCoreRT))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreCoreRTTest));
            }
        }
        /// <summary>
        /// Gets the trait values from the Category attribute.
        /// </summary>
        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
        /// <returns>The trait values.</returns>
        public IEnumerable <KeyValuePair <string, string> > GetTraits(IAttributeInfo traitAttribute)
        {
            TargetFrameworkMonikers platform = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();

            if (platform.HasFlag(TargetFrameworkMonikers.Net45))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet45Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net451))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet451Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net452))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet452Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net46))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet46Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net461))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet461Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net462))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet462Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Net463))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNet463Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcore50))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcore50aot))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcore50aotTest));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_0))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_0Test));
            }
            if (platform.HasFlag(TargetFrameworkMonikers.Netcoreapp1_1))
            {
                yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.NonNetcoreapp1_1Test));
            }
        }