public IEnumerable <Step> Scan(ITestContext testContext, MethodInfo method, Example example) { var executableAttribute = (ExecutableAttribute)method.GetCustomAttributes(typeof(ExecutableAttribute), true).FirstOrDefault(); if (executableAttribute == null) { yield break; } string stepTitle = executableAttribute.StepTitle; if (string.IsNullOrEmpty(stepTitle)) { stepTitle = Configurator.Scanners.Humanize(method.Name); } var stepAsserts = IsAssertingByAttribute(method); var shouldReport = executableAttribute.ShouldReport; var methodParameters = method.GetParameters(); var inputs = new List <object>(); var inputPlaceholders = Regex.Matches(stepTitle, " <(\\w+)> "); for (int i = 0; i < inputPlaceholders.Count; i++) { var placeholder = inputPlaceholders[i].Groups[1].Value; for (int j = 0; j < example.Headers.Length; j++) { if (example.Values.ElementAt(j).MatchesName(placeholder)) { inputs.Add(example.GetValueOf(j, methodParameters[inputs.Count].ParameterType)); break; } } } var stepAction = StepActionFactory.GetStepAction(method, inputs.ToArray()); yield return(new Step(stepAction, new StepTitle(stepTitle), stepAsserts, executableAttribute.ExecutionOrder, shouldReport, new List <StepArgument>())); }
private Step GetStep(object testObject, MethodNameMatcher matcher, MethodInfo method, bool returnsItsText, Example example) { var stepMethodName = GetStepTitleFromMethodName(method, null); var methodParameters = method.GetParameters(); var inputs = new object[methodParameters.Length]; for (var parameterIndex = 0; parameterIndex < inputs.Length; parameterIndex++) { for (var exampleIndex = 0; exampleIndex < example.Headers.Length; exampleIndex++) { var methodParameter = methodParameters[parameterIndex]; var parameterName = methodParameter.Name; var placeholderMatchesExampleColumn = example.Values.ElementAt(exampleIndex).MatchesName(parameterName); if (placeholderMatchesExampleColumn) { inputs[parameterIndex] = example.GetValueOf(exampleIndex, methodParameter.ParameterType); } } } var stepAction = GetStepAction(method, inputs.ToArray(), returnsItsText); return(new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, new List <StepArgument>())); }
public IEnumerable<Step> Scan(ITestContext testContext, MethodInfo method, Example example) { var executableAttribute = (ExecutableAttribute)method.GetCustomAttributes(typeof(ExecutableAttribute), false).FirstOrDefault(); if (executableAttribute == null) yield break; string stepTitle = executableAttribute.StepTitle; if (string.IsNullOrEmpty(stepTitle)) stepTitle = Configurator.Scanners.Humanize(method.Name); var stepAsserts = IsAssertingByAttribute(method); var methodParameters = method.GetParameters(); var inputs = new List<object>(); var inputPlaceholders = Regex.Matches(stepTitle, " <(\\w+)> "); for (int i = 0; i < inputPlaceholders.Count; i++) { var placeholder = inputPlaceholders[i].Groups[1].Value; for (int j = 0; j < example.Headers.Length; j++) { if (example.Values.ElementAt(j).MatchesName(placeholder)) { inputs.Add(example.GetValueOf(j, methodParameters[inputs.Count].ParameterType)); break; } } } var stepAction = StepActionFactory.GetStepAction(method, inputs.ToArray()); yield return new Step(stepAction, new StepTitle(stepTitle), stepAsserts, executableAttribute.ExecutionOrder, true, new List<StepArgument>()); }
private Step GetStep(object testObject, MethodNameMatcher matcher, MethodInfo method, bool returnsItsText, Example example) { var stepMethodName = GetStepTitleFromMethodName(method, null); var methodParameters = method.GetParameters(); var inputs = new object[methodParameters.Length]; for (var parameterIndex = 0; parameterIndex < inputs.Length; parameterIndex++) { for (var exampleIndex = 0; exampleIndex < example.Headers.Length; exampleIndex++) { var methodParameter = methodParameters[parameterIndex]; var parameterName = methodParameter.Name; var placeholderMatchesExampleColumn = example.Values.ElementAt(exampleIndex).MatchesName(parameterName); if (placeholderMatchesExampleColumn ) inputs[parameterIndex] = example.GetValueOf(exampleIndex, methodParameter.ParameterType); } } var stepAction = GetStepAction(method, inputs.ToArray(), returnsItsText); return new Step(stepAction, new StepTitle(stepMethodName), matcher.Asserts, matcher.ExecutionOrder, matcher.ShouldReport, new List<StepArgument>()); }