Beispiel #1
0
        private TestStep CreateTestStep(IMethodCallMessage methodCall, MethodInfo testMethod, Status caseStatus, int index)
        {
            var testStep   = new TestStep();
            var args       = methodCall.Args;
            var paramStr   = string.Empty;
            var paramInfos = testMethod.GetParameters();

            if (paramInfos.Any())
            {
                if (methodCall.ArgCount == paramInfos.Length)
                {
                    for (int i = 0; i < paramInfos.Length; i++)
                    {
                        if (args[i].GetType() == typeof(List <string>))
                        {
                            paramStr = $"{paramStr}, {paramInfos[i].ParameterType.Name} {paramInfos[i].Name} = '{string.Join(", ", args[i] as List<string>)}'";
                        }
                        else
                        {
                            paramStr = $"{paramStr}, {paramInfos[i].ParameterType.Name} {paramInfos[i].Name} = '{args[i]}'";
                        }
                    }
                }
                else
                {
                    foreach (var paramInfo in paramInfos)
                    {
                        paramStr = $"{paramStr}, {paramInfo.ParameterType.Name} {paramInfo.Name}";
                    }
                }

                paramStr = $"({paramStr.Trim(',').Trim()})";
            }

            testStep.SetName($"{testMethod.Name} {paramStr}".Trim());
            testStep.SetIndex(index);

            var stepAttr = testMethod.TestStep();

            testStep.SetID(stepAttr.ID);
            testStep.SetComment(stepAttr.Comment);

            if (caseStatus != Status.Undefined)
            {
                stepAttr.Status = caseStatus;
            }

            testStep.SetStatus(stepAttr.Status);

            return(testStep);
        }