/// <inheritdoc/> public virtual IEnumerable <KeyValuePair <string, string> > GetTraits(_IAttributeInfo traitAttribute) { Guard.ArgumentNotNull(nameof(traitAttribute), traitAttribute); var ctorArgs = traitAttribute.GetConstructorArguments().Cast <string>().ToList(); yield return(new KeyValuePair <string, string>(ctorArgs[0], ctorArgs[1])); }
/// <inheritdoc/> public virtual IReadOnlyCollection <KeyValuePair <string, string> > GetTraits(_IAttributeInfo traitAttribute) { Guard.ArgumentNotNull(traitAttribute); var ctorArgs = traitAttribute .GetConstructorArguments() .Cast <string>() .ToList(); return(new[] { new KeyValuePair <string, string>(ctorArgs[0], ctorArgs[1]) }); }
static string[] GetCultures(_IAttributeInfo culturedTheoryAttribute) { var ctorArgs = culturedTheoryAttribute.GetConstructorArguments().ToArray(); var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast <string[]>().Single(); if (cultures == null || cultures.Length == 0) { cultures = new[] { "en-US", "fr-FR" } } ; return(cultures); } }
/// <inheritdoc/> public Type?GetTestFrameworkType(_IAttributeInfo attribute) { Guard.ArgumentNotNull(nameof(attribute), attribute); var args = attribute.GetConstructorArguments().ToArray(); if (args.Length == 1) { return((Type)args[0] !); } var stringArgs = args.Cast <string>().ToArray(); return(SerializationHelper.GetType(stringArgs[1], stringArgs[0])); }
/// <inheritdoc/> public virtual IEnumerable <object?[]> GetData( _IAttributeInfo dataAttribute, _IMethodInfo testMethod) { // The data from GetConstructorArguments does not maintain its original form (in particular, collections // end up as generic IEnumerable<T>). So we end up needing to call .ToArray() on the enumerable so that // we can restore the correct argument type from InlineDataAttribute. // // In addition, [InlineData(null)] gets translated into passing a null array, not a single array with a null // value in it, which is why the null coalesce operator is required (this is covered by the acceptance test // in Xunit2TheoryAcceptanceTests.InlineDataTests.SingleNullValuesWork). var args = (IEnumerable <object?>?)dataAttribute.GetConstructorArguments().Single() ?? new object?[] { null }; return(new[] { args.ToArray() }); }
public ValueTask <IReadOnlyCollection <IXunitTestCase> > Discover( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo factAttribute) { var ctorArgs = factAttribute.GetConstructorArguments().ToArray(); var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast <string[]>().Single(); if (cultures == null || cultures.Length == 0) { cultures = new[] { "en-US", "fr-FR" } } ; var methodDisplay = discoveryOptions.MethodDisplayOrDefault(); var methodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault(); var result = cultures .Select(culture => CreateTestCase(testMethod, culture, methodDisplay, methodDisplayOptions)) .CastOrToReadOnlyCollection(); return(new(result)); } CulturedXunitTestCase CreateTestCase( _ITestMethod testMethod, string culture, TestMethodDisplay methodDisplay, TestMethodDisplayOptions methodDisplayOptions) { return(new CulturedXunitTestCase( methodDisplay, methodDisplayOptions, testMethod, culture )); } }
public IEnumerable <IXunitTestCase> Discover( _ITestFrameworkDiscoveryOptions discoveryOptions, _ITestMethod testMethod, _IAttributeInfo factAttribute) { var ctorArgs = factAttribute.GetConstructorArguments().ToArray(); var cultures = Reflector.ConvertArguments(ctorArgs, new[] { typeof(string[]) }).Cast <string[]>().Single(); if (cultures == null || cultures.Length == 0) { cultures = new[] { "en-US", "fr-FR" } } ; var methodDisplay = discoveryOptions.MethodDisplayOrDefault(); var methodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault(); return (cultures .Select(culture => CreateTestCase(testMethod, culture, methodDisplay, methodDisplayOptions)) .ToList()); } CulturedXunitTestCase CreateTestCase( _ITestMethod testMethod, string culture, TestMethodDisplay methodDisplay, TestMethodDisplayOptions methodDisplayOptions) { return(new CulturedXunitTestCase( diagnosticMessageSink, methodDisplay, methodDisplayOptions, testMethod, culture )); } }
public IEnumerable <KeyValuePair <string, string> > GetTraits(_IAttributeInfo traitAttribute) { var ctorArgs = traitAttribute.GetConstructorArguments().ToList(); yield return(new KeyValuePair <string, string>("Bug", ctorArgs[0] !.ToString() !)); }
public IReadOnlyCollection <KeyValuePair <string, string> > GetTraits(_IAttributeInfo traitAttribute) { var ctorArgs = traitAttribute.GetConstructorArguments().ToList(); return(new[] { new KeyValuePair <string, string>("Bug", ctorArgs[0] !.ToString() !) });