示例#1
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope, int hookOrder)
     : base(bindingMethod)
 {
     HookOrder = hookOrder;
     HookType = hookType;
     BindingScope = bindingScope;
 }
示例#2
0
 public IStepDefinitionBinding CreateStepBinding(StepDefinitionType type, string regexString,
     IBindingMethod bindingMethod, BindingScope bindingScope)
 {
     if (regexString == null)
         regexString = stepDefinitionRegexCalculator.CalculateRegexFromMethod(type, bindingMethod);
     return new StepDefinitionBinding(type, regexString, bindingMethod, bindingScope);
 }
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, Regex regex, IBindingMethod bindingMethod, BindingScope bindingScope)
     : base(bindingMethod)
 {
     StepDefinitionType = stepDefinitionType;
     Regex        = regex;
     BindingScope = bindingScope;
 }
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, Regex regex, IBindingMethod bindingMethod, BindingScope bindingScope)
     : base(bindingMethod)
 {
     StepDefinitionType = stepDefinitionType;
     Regex = regex;
     BindingScope = bindingScope;
 }
示例#5
0
 public StepBinding(IBindingMethod method, BindingType bindingType, Regex regex, BindingScope bindingScope)
 {
     Method = method;
     BindingType = bindingType;
     Regex = regex;
     BindingScope = bindingScope;
 }
示例#6
0
 public StepBinding(IBindingMethod method, BindingType bindingType, Regex regex, BindingScope bindingScope)
 {
     Method       = method;
     BindingType  = bindingType;
     Regex        = regex;
     BindingScope = bindingScope;
 }
 private IEnumerable<StepBinding> GetSuggestionsFromCodeFunctionForScope(CodeFunction codeFunction, BindingScope bindingScope)
 {
     return codeFunction.Attributes.Cast<CodeAttribute2>()
         .Select(codeAttribute => GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.Given, bindingScope) ??
                                  GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.When, bindingScope) ??
                                  GetBingingFromAttribute(codeAttribute, codeFunction, BindingType.Then, bindingScope))
         .Where(binding => binding != null);
 }
示例#8
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (int)HookType;
         hashCode = (hashCode * 397) ^ HookOrder;
         hashCode = (hashCode * 397) ^ (BindingScope != null ? BindingScope.GetHashCode() : 0);
         return(hashCode);
     }
 }
示例#9
0
 private void AddStepBinding(MethodInfo method, StepDefinitionBaseAttribute stepDefinitionBaseAttr, BindingScope stepScope)
 {
     foreach (var bindingType in stepDefinitionBaseAttr.Types)
     {
         var stepBinding = bindingFactory.CreateStepBinding(bindingType, stepDefinitionBaseAttr.Regex, method, stepScope);
         stepBindings.Add(stepBinding);
     }
 }
示例#10
0
 public EventBinding CreateEventBinding(MethodInfo methodInfo, BindingScope bindingScope)
 {
     return new EventBinding(runtimeConfiguration, errorProvider, methodInfo, bindingScope);
 }
示例#11
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope) : base(bindingMethod)
 {
     HookType     = hookType;
     BindingScope = bindingScope;
 }
        private StepDefinitionBinding CreateStepBinding(CodeAttribute2 attr, CodeFunction codeFunction, StepDefinitionType stepDefinitionType, BindingScope bindingScope)
        {
            try
            {
                IBindingMethod bindingMethod = bindingReflectionFactory.CreateBindingMethod(codeFunction);

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

                var regexString = VsxHelper.ParseCodeStringValue(regexArg.Value, regexArg.Language);

                return new StepDefinitionBinding(stepDefinitionType, regexString, bindingMethod, bindingScope);
            }
            catch(Exception)
            {
                return null;
            }
        }
示例#13
0
        public StepDefinitionBinding(RuntimeConfiguration runtimeConfiguration, IErrorProvider errorProvider, BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
            : base(runtimeConfiguration, errorProvider, methodInfo)
        {
            Type = type;
            Regex regex = new Regex("^" + regexString + "$", RegexOptions);

            Regex             = regex;
            this.BindingScope = bindingScope;
        }
 private IEnumerable<StepDefinitionBinding> GetStepsFromClass(CodeClass codeClass, BindingScope[] classScopes)
 {
     return codeClass.Children.OfType<CodeFunction>().SelectMany(codeFunction => GetSuggestionsFromCodeFunction(codeFunction, classScopes));
 }
示例#15
0
 public EventBinding(RuntimeConfiguration runtimeConfiguration, IErrorProvider errorProvider, MethodInfo methodInfo, BindingScope bindingScope)
     : base(runtimeConfiguration, errorProvider, methodInfo)
 {
     BindingScope = bindingScope;
 }
示例#16
0
 public IHookBinding CreateHookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope,
                                       int hookOrder)
 {
     return(new HookBinding(bindingMethod, hookType, bindingScope, hookOrder));
 }
 private StepBinding GetBingingFromAttribute(CodeAttribute2 codeAttribute, CodeFunction codeFunction, BindingType bindingType, BindingScope 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;
     }
 }
        private StepBinding CreateStepBinding(CodeAttribute2 attr, CodeFunction codeFunction, BindingType bindingType, BindingScope 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 StepBinding(bindingMethod, bindingType, regex, bindingScope);
            }
            catch(Exception)
            {
                return null;
            }
        }
示例#19
0
 protected bool Equals(BindingScope other)
 {
     return(string.Equals(Tag, other.Tag) && string.Equals(FeatureTitle, other.FeatureTitle) && string.Equals(ScenarioTitle, other.ScenarioTitle));
 }
示例#20
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope, int hookOrder) : base(bindingMethod)
 {
     HookOrder    = hookOrder;
     HookType     = hookType;
     BindingScope = bindingScope;
 }
示例#21
0
 public HookBinding(RuntimeConfiguration runtimeConfiguration, IErrorProvider errorProvider, MethodInfo methodInfo, BindingScope bindingScope)
     : base(runtimeConfiguration, errorProvider, methodInfo)
 {
     BindingScope = bindingScope;
 }
示例#22
0
 public IHookBinding CreateEventBinding(IBindingMethod bindingMethod, BindingScope bindingScope)
 {
     return new HookBinding(bindingMethod, bindingScope);
 }
示例#23
0
 private void AddStepBinding(IBindingMethod bindingMethod, StepDefinitionBaseAttribute stepDefinitionBaseAttr, BindingScope stepScope)
 {
     foreach (var bindingType in stepDefinitionBaseAttr.Types)
     {
         var stepBinding = bindingFactory.CreateStepBinding(bindingType, stepDefinitionBaseAttr.Regex, bindingMethod, stepScope);
         stepDefinitions.Add(stepBinding);
     }
 }
 private IEnumerable<StepDefinitionBinding> GetSuggestionsFromCodeFunctionForScope(CodeFunction codeFunction, BindingScope bindingScope)
 {
     return codeFunction.Attributes.Cast<CodeAttribute2>()
         .SelectMany(codeAttribute => GetStepDefinitionsFromAttribute(codeAttribute, codeFunction, bindingScope))
         .Where(binding => binding != null);
 }
示例#25
0
 public HookBinding(IBindingMethod bindingMethod, BindingScope bindingScope) : base(bindingMethod)
 {
     BindingScope = bindingScope;
 }
示例#26
0
 public IStepDefinitionBinding CreateStepBinding(StepDefinitionType type, string regexString,
                                                 IBindingMethod bindingMethod, BindingScope bindingScope)
 {
     if (regexString == null)
     {
         regexString = stepDefinitionRegexCalculator.CalculateRegexFromMethod(type, bindingMethod);
     }
     return(new StepDefinitionBinding(type, regexString, bindingMethod, bindingScope));
 }
示例#27
0
 public IHookBinding CreateEventBinding(MethodInfo methodInfo, BindingScope bindingScope)
 {
     return(new HookBinding(runtimeConfiguration, errorProvider, methodInfo, bindingScope));
 }
示例#28
0
 public IHookBinding CreateHookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope)
 {
     return new HookBinding(bindingMethod, hookType, bindingScope);
 }
        private IEnumerable<StepDefinitionBinding> GetStepDefinitionsFromAttribute(CodeAttribute2 codeAttribute, CodeFunction codeFunction, BindingScope bindingScope)
        {
            var normalStepDefinition =
                GetBingingFromAttribute(codeAttribute, codeFunction, StepDefinitionType.Given, bindingScope) ??
                GetBingingFromAttribute(codeAttribute, codeFunction, StepDefinitionType.When, bindingScope) ??
                GetBingingFromAttribute(codeAttribute, codeFunction, StepDefinitionType.Then, bindingScope);
            if (normalStepDefinition != null)
            {
                yield return normalStepDefinition;
                yield break;
            }

            if (IsGeneralStepDefinition(codeAttribute))
            {
                yield return CreateStepBinding(codeAttribute, codeFunction, StepDefinitionType.Given, bindingScope);
                yield return CreateStepBinding(codeAttribute, codeFunction, StepDefinitionType.When, bindingScope);
                yield return CreateStepBinding(codeAttribute, codeFunction, StepDefinitionType.Then, bindingScope);
            }
        }
示例#30
0
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, string regexString, IBindingMethod bindingMethod, BindingScope bindingScope)
     : this(stepDefinitionType, RegexFactory.Create(regexString), bindingMethod, bindingScope)
 {
 }
示例#31
0
        private void AddStepBinding(MethodInfo method, ScenarioStepAttribute scenarioStepAttr, BindingScope stepScope)
        {
            StepBinding stepBinding = new StepBinding(scenarioStepAttr.Type, scenarioStepAttr.Regex, method, stepScope);

            stepBindings.Add(stepBinding);
        }
示例#32
0
 protected bool Equals(BindingScope other)
 {
     return string.Equals(Tag, other.Tag) && string.Equals(FeatureTitle, other.FeatureTitle) && string.Equals(ScenarioTitle, other.ScenarioTitle);
 }
示例#33
0
 protected override void ProcessHooks(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     //nop - not needed for IDE integration
 }
示例#34
0
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, string regexString, IBindingMethod bindingMethod, BindingScope bindingScope)
     : this(stepDefinitionType, RegexFactory.Create(regexString), bindingMethod, bindingScope)
 {
 }
示例#35
0
 protected override void ProcessStepArgumentTransformations(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     //nop - not needed for IDE integration
 }
示例#36
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope) : base(bindingMethod)
 {
     HookType = hookType;
     BindingScope = bindingScope;
 }
示例#37
0
 public StepBinding CreateStepBinding(BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
 {
     return new StepBinding(runtimeConfiguration, errorProvider, type, regexString, methodInfo, bindingScope);
 }
示例#38
0
 public StepDefinitionBinding CreateStepBinding(BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
 {
     return(new StepDefinitionBinding(runtimeConfiguration, errorProvider, type, regexString, methodInfo, bindingScope));
 }
示例#39
0
        public StepBinding(BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
            : base(methodInfo)
        {
            Type = type;
            Regex regex = new Regex("^" + regexString + "$", RegexOptions);

            Regex             = regex;
            this.BindingScope = bindingScope;
        }