/// <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.Any; TestRuntimes runtimes = TestRuntimes.Any; Type calleeType = null; string[] conditionMemberNames = null; 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; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } else if (arg is Type) { calleeType = (Type)arg; } else if (arg is string[]) { conditionMemberNames = (string[])arg; } } if (calleeType != null && conditionMemberNames != null) { if (!DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } } else if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes) && DiscovererHelpers.TestFrameworkApplies(frameworks)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } }
internal static IEnumerable <KeyValuePair <string, string> > EvaluateArguments(IEnumerable <object> ctorArgs, string category, int skipFirst = 1) { Debug.Assert(ctorArgs.Count() >= 2); TestPlatforms platforms = TestPlatforms.Any; TargetFrameworkMonikers frameworks = TargetFrameworkMonikers.Any; TestRuntimes runtimes = TestRuntimes.Any; Type calleeType = null; string[] conditionMemberNames = null; foreach (object arg in ctorArgs.Skip(skipFirst)) // First argument is the issue number or reason. { if (arg is TestPlatforms) { platforms = (TestPlatforms)arg; } else if (arg is TargetFrameworkMonikers) { frameworks = (TargetFrameworkMonikers)arg; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } else if (arg is Type) { calleeType = (Type)arg; } else if (arg is string[]) { conditionMemberNames = (string[])arg; } } if (calleeType != null && conditionMemberNames != null) { if (DiscovererHelpers.Evaluate(calleeType, conditionMemberNames)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, category)); } } else if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes) && DiscovererHelpers.TestFrameworkApplies(frameworks)) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, category)); } }
/// <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; TestRuntimes runtimes = TestRuntimes.Any; 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; } else if (arg is TestRuntimes) { runtimes = (TestRuntimes)arg; } } if (DiscovererHelpers.TestPlatformApplies(platforms) && DiscovererHelpers.TestRuntimeApplies(runtimes)) { 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 == (TargetFrameworkMonikers)0) { yield return(new KeyValuePair <string, string>(XunitConstants.Category, XunitConstants.Failing)); } } }
public static bool TestRuntimeApplies(TestRuntimes runtimes) => (runtimes.HasFlag(TestRuntimes.Mono) && IsMonoRuntime) || (runtimes.HasFlag(TestRuntimes.CoreCLR) && !IsMonoRuntime); // assume CoreCLR if it's not Mono
public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = TargetFrameworkMonikers.Any, TestRuntimes runtimes = TestRuntimes.Any) { }
public ActiveIssueAttribute(string issue, TestRuntimes runtimes) { }
internal static bool TestRuntimeApplies(TestRuntimes runtimes) => (runtimes.HasFlag(TestRuntimes.Mono) && SkipOnMonoDiscoverer.IsMonoRuntime) || (runtimes.HasFlag(TestRuntimes.CoreCLR) && !SkipOnMonoDiscoverer.IsMonoRuntime); // assume CoreCLR if it's not Mono
public OuterLoopAttribute(string reason, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = TargetFrameworkMonikers.Any, TestRuntimes runtimes = TestRuntimes.Any) { }
public OuterLoopAttribute(string reason, TestRuntimes runtimes) { }