Beispiel #1
0
        private void BuildStepStatement(string indent, StringBuilder stepOfScenario)
        {
            string stepTextByEscapingQuotaion = StepText.Replace("\"", "\\\"");

            stepOfScenario
            .Append(indent + StepKeyword + "(L\"" + stepTextByEscapingQuotaion + "\"")
            .Append(BuildStepRealArg())
            .Append(");");
        }
        protected override string ConvertParameters(Dictionary <string, object> parameters)
        {
            foreach (var valuePair in parameters)
            {
                var match = Regex.Match(StepText, $"&{valuePair.Key}&");
                if (!match.Success)
                {
                    var matches = Regex.Matches(StepText, $"&{valuePair.Key}\\.(.*?)&");
                    foreach (Match match1 in matches)
                    {
                        if (!match1.Success || match1.Groups.Count < 2)
                        {
                            continue;
                        }
                        var obj        = valuePair.Value;
                        var call       = match1.Groups[1].Value;
                        var firstIndex = call.LastIndexOf('(');
                        if (firstIndex != -1)
                        {
                            var lastIndex = call.LastIndexOf(')');
                            if (lastIndex - firstIndex > 1)
                            {
                                throw new ArgumentException("Sorry, you cannot use methods with parameters in AllureStep at the moment.\nThis will be added in later releases.");
                            }
                            call = call.Remove(firstIndex, lastIndex - firstIndex + 1);
                        }
                        var member = ReflectionHelper.GetMember(obj.GetType(), call);
                        if (member != null)
                        {
                            var memberValue = ReflectionHelper.GetMemberValue(member, obj);
                            StepText = StepText.Replace(match1.Value, memberValue?.ToString());
                        }
                    }
                }
                else
                {
                    var val = match.Value;
                    StepText = StepText.Replace(val, valuePair.Value?.ToString());
                }
            }

            return(StepText);
        }
Beispiel #3
0
 public bool HasMockAttribute()
 {
     return(StepText.Contains(BDDUtil.MockAttrSymbol));
 }