Skip to content

Handle more than three parameters for TestCase #1

@busterwood

Description

@busterwood
        object[] TestCaseArgs()
        {
            var args = testCase.ConstructorArguments.Select(arg => arg.Value).ToArray();
            if (args.Length == 1 && args[0] is ReadOnlyCollection<CustomAttributeTypedArgument> caArgs)
            {
                args = caArgs.Select(ca => ca.Value).ToArray();
            }

            int i = 0;
            foreach (var p in test.GetParameters())
            {
                var arg = args[i];
                if (arg != null && p.ParameterType != arg.GetType() && !p.ParameterType.IsEnum)
                    args[i] = Convert.ChangeType(arg, p.ParameterType);
                i++;
            }
            return args;
        }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions