Exemple #1
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope, int hookOrder)
     : base(bindingMethod)
 {
     HookOrder = hookOrder;
     HookType = hookType;
     BindingScope = bindingScope;
 }
 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;
 }
Exemple #5
0
 public StepBinding(IBindingMethod method, BindingType bindingType, Regex regex, BindingScope bindingScope)
 {
     Method = method;
     BindingType = bindingType;
     Regex = regex;
     BindingScope = bindingScope;
 }
Exemple #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);
 }
Exemple #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);
     }
 }
 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);
     }
 }
Exemple #10
0
 public EventBinding CreateEventBinding(MethodInfo methodInfo, BindingScope bindingScope)
 {
     return new EventBinding(runtimeConfiguration, errorProvider, methodInfo, bindingScope);
 }
Exemple #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;
            }
        }
        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));
 }
Exemple #15
0
 public EventBinding(RuntimeConfiguration runtimeConfiguration, IErrorProvider errorProvider, MethodInfo methodInfo, BindingScope bindingScope)
     : base(runtimeConfiguration, errorProvider, methodInfo)
 {
     BindingScope = bindingScope;
 }
Exemple #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;
            }
        }
Exemple #19
0
 protected bool Equals(BindingScope other)
 {
     return(string.Equals(Tag, other.Tag) && string.Equals(FeatureTitle, other.FeatureTitle) && string.Equals(ScenarioTitle, other.ScenarioTitle));
 }
Exemple #20
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope, int hookOrder) : base(bindingMethod)
 {
     HookOrder    = hookOrder;
     HookType     = hookType;
     BindingScope = bindingScope;
 }
Exemple #21
0
 public HookBinding(RuntimeConfiguration runtimeConfiguration, IErrorProvider errorProvider, MethodInfo methodInfo, BindingScope bindingScope)
     : base(runtimeConfiguration, errorProvider, methodInfo)
 {
     BindingScope = bindingScope;
 }
Exemple #22
0
 public IHookBinding CreateEventBinding(IBindingMethod bindingMethod, BindingScope bindingScope)
 {
     return new HookBinding(bindingMethod, bindingScope);
 }
 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);
 }
Exemple #25
0
 public HookBinding(IBindingMethod bindingMethod, BindingScope bindingScope) : base(bindingMethod)
 {
     BindingScope = bindingScope;
 }
Exemple #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));
 }
Exemple #27
0
 public IHookBinding CreateEventBinding(MethodInfo methodInfo, BindingScope bindingScope)
 {
     return(new HookBinding(runtimeConfiguration, errorProvider, methodInfo, bindingScope));
 }
Exemple #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);
            }
        }
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, string regexString, IBindingMethod bindingMethod, BindingScope bindingScope)
     : this(stepDefinitionType, RegexFactory.Create(regexString), bindingMethod, bindingScope)
 {
 }
Exemple #31
0
        private void AddStepBinding(MethodInfo method, ScenarioStepAttribute scenarioStepAttr, BindingScope stepScope)
        {
            StepBinding stepBinding = new StepBinding(scenarioStepAttr.Type, scenarioStepAttr.Regex, method, stepScope);

            stepBindings.Add(stepBinding);
        }
Exemple #32
0
 protected bool Equals(BindingScope other)
 {
     return string.Equals(Tag, other.Tag) && string.Equals(FeatureTitle, other.FeatureTitle) && string.Equals(ScenarioTitle, other.ScenarioTitle);
 }
 protected override void ProcessHooks(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     //nop - not needed for IDE integration
 }
 public StepDefinitionBinding(StepDefinitionType stepDefinitionType, string regexString, IBindingMethod bindingMethod, BindingScope bindingScope)
     : this(stepDefinitionType, RegexFactory.Create(regexString), bindingMethod, bindingScope)
 {
 }
 protected override void ProcessStepArgumentTransformations(BindingSourceMethod bindingSourceMethod, BindingScope[] methodScopes)
 {
     //nop - not needed for IDE integration
 }
Exemple #36
0
 public HookBinding(IBindingMethod bindingMethod, HookType hookType, BindingScope bindingScope) : base(bindingMethod)
 {
     HookType = hookType;
     BindingScope = bindingScope;
 }
Exemple #37
0
 public StepBinding CreateStepBinding(BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
 {
     return new StepBinding(runtimeConfiguration, errorProvider, type, regexString, methodInfo, bindingScope);
 }
Exemple #38
0
 public StepDefinitionBinding CreateStepBinding(BindingType type, string regexString, MethodInfo methodInfo, BindingScope bindingScope)
 {
     return(new StepDefinitionBinding(runtimeConfiguration, errorProvider, type, regexString, methodInfo, bindingScope));
 }
Exemple #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;
        }