Exemplo n.º 1
0
        public StepMatch GetMatch(Step step, ActionStepMethod stepMethod)
        {
            if (step.StepType != stepMethod.StepType) return StepMatch.NoMatch(step);

            var stepTokens = Tokenize(step.Text);
            var methodTokens = Tokenize(stepMethod.Text);

            if (stepTokens.Length != methodTokens.Length) return StepMatch.NoMatch(step);

            var tokens = new List<Token>();

            for (var index = 0; index < stepTokens.Length; index++)
            {
                var tok1 = stepTokens[index];
                var tok2 = methodTokens[index];

                if (tok2 is VariableToken)
                {
                    ((VariableToken) tok2).Value = tok1.Text;
                    tokens.Add(tok2);
                    continue;
                }

                if (tok1.Text != tok2.Text)
                {
                    return StepMatch.NoMatch(step);
                }

                tokens.Add(tok1);
            }

            return new StepMatch(step) {IsMatch = true, Tokens = tokens};
        }
 void AssertStepMethod(ActionStepMethod method, StepType expectedStepType, string expectedText)
 {
     Assert.AreEqual(expectedStepType, method.StepType);
     Assert.AreEqual(expectedText, method.Text);
 }