Xunit.ValuesUtilities.GetValuesFor C# (CSharp) Method

GetValuesFor() static private method

Gets a sequence of values that should be tested for the specified parameter.
static private GetValuesFor ( ParameterInfo parameter ) : IEnumerable
parameter System.Reflection.ParameterInfo The parameter to get possible values for.
return IEnumerable
        internal static IEnumerable<object> GetValuesFor(ParameterInfo parameter)
        {
            Requires.NotNull(parameter, nameof(parameter));

            var valuesAttribute = parameter.GetCustomAttribute<CombinatorialValuesAttribute>();
            if (valuesAttribute != null)
            {
                return valuesAttribute.Values;
            }

            return GetValuesFor(parameter.ParameterType);
        }

Same methods

ValuesUtilities::GetValuesFor ( Type dataType ) : IEnumerable

Usage Example

示例#1
0
        /// <inheritdoc />
        public override IEnumerable <object[]> GetData(MethodInfo testMethod)
        {
            Requires.NotNull(testMethod, nameof(testMethod));

            var parameters = testMethod.GetParameters();

            if (parameters.Length == 0)
            {
                return(Enumerable.Empty <object[]>());
            }

            var values = new List <object> [parameters.Length];

            for (int i = 0; i < parameters.Length; i++)
            {
                values[i] = ValuesUtilities.GetValuesFor(parameters[i]).ToList();
            }

            var currentValues = new object[parameters.Length];

            return(this.FillCombinations(parameters, values, currentValues, 0));
        }
All Usage Examples Of Xunit.ValuesUtilities::GetValuesFor
ValuesUtilities