Exemplo n.º 1
0
 private IEnumerable <StepBindingNew> GetSuggestionsFromCodeFunctionForScope(CodeFunction codeFunction, BindingScopeNew bindingScope)
 {
     return(codeFunction.Attributes.Cast <CodeAttribute2>()
            .SelectMany(codeAttribute => GetStepDefinitionsFromAttribute(codeAttribute, codeFunction, bindingScope))
            .Where(binding => binding != null));
 }
Exemplo n.º 2
0
 private StepBindingNew GetBingingFromAttribute(CodeAttribute2 codeAttribute, CodeFunction codeFunction, BindingType bindingType, BindingScopeNew bindingScope)
 {
     try
     {
         if (codeAttribute.FullName.Equals(string.Format("TechTalk.SpecFlow.{0}Attribute", bindingType)))
         {
             return(CreateStepBinding(codeAttribute, codeFunction, bindingType, bindingScope));
         }
         return(null);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        private StepBindingNew CreateStepBinding(CodeAttribute2 attr, CodeFunction codeFunction, BindingType bindingType, BindingScopeNew bindingScope)
        {
            try
            {
                IBindingMethod bindingMethod = new VsBindingMethod(codeFunction);

                var regexArg = attr.Arguments.Cast <CodeAttributeArgument>().FirstOrDefault();
                if (regexArg == null)
                {
                    return(null);
                }

                var regexString = VsxHelper.ParseCodeStringValue(regexArg.Value, regexArg.Language);
                var regex       = new Regex("^" + regexString + "$", RegexOptions.Compiled | RegexOptions.CultureInvariant);

                return(new StepBindingNew(bindingMethod, bindingType, regex, bindingScope));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        private IEnumerable <StepBindingNew> GetStepDefinitionsFromAttribute(CodeAttribute2 codeAttribute, CodeFunction codeFunction, BindingScopeNew bindingScope)
        {
            var normalStepDefinition =
                GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.Given, bindingScope) ??
                GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.When, bindingScope) ??
                GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.Then, bindingScope);

            if (normalStepDefinition != null)
            {
                yield return(normalStepDefinition);

                yield break;
            }

            if (IsGeneralStepDefinition(codeAttribute))
            {
                yield return(CreateStepBinding(codeAttribute, codeFunction, BindingType.Given, bindingScope));

                yield return(CreateStepBinding(codeAttribute, codeFunction, BindingType.When, bindingScope));

                yield return(CreateStepBinding(codeAttribute, codeFunction, BindingType.Then, bindingScope));
            }
        }