示例#1
0
        public StepKeyword? TryParseStepKeyword(string keyword)
        {
            if (NativeLanguageService.keywords("and").contains(keyword))
                return StepKeyword.And;
            // this is checked at the first place to interpret "*" as "and"

            if (NativeLanguageService.keywords("given").contains(keyword))
                return StepKeyword.Given;

            if (NativeLanguageService.keywords("when").contains(keyword))
                return StepKeyword.When;

            if (NativeLanguageService.keywords("then").contains(keyword))
                return StepKeyword.Then;

            if (NativeLanguageService.keywords("but").contains(keyword))
                return StepKeyword.But;

            // In Gherkin, the space at the end is also part of the keyword, becase in some 
            // languages, there is no space between the step keyword and the step text.
            // To support the keywords without leading space as well, we retry the matching with 
            // an additional space too.
            if (!keyword.EndsWith(" "))
                return TryParseStepKeyword(keyword + " ");

            return null;
        }
示例#2
0
        public IEnumerable<string> GetBlockKeywords(GherkinBlockKeyword blockKeyword)
        {
            string key = blockKeyword.ToString().ToLowerInvariant();
            if (blockKeyword == GherkinBlockKeyword.ScenarioOutline)
                key = "scenario_outline";

            return NativeLanguageService.keywords(key).toArray().Cast<string>();
        }
示例#3
0
        public IEnumerable <string> GetBlockKeywords()
        {
            var keywords = Enumerable.Empty <string>();

            keywords = keywords.Concat(NativeLanguageService.keywords("feature").toArray().Cast <string>());
            keywords = keywords.Concat(NativeLanguageService.keywords("background").toArray().Cast <string>());
            keywords = keywords.Concat(NativeLanguageService.keywords("scenario").toArray().Cast <string>());
            keywords = keywords.Concat(NativeLanguageService.keywords("scenario_outline").toArray().Cast <string>());
            keywords = keywords.Concat(NativeLanguageService.keywords("examples").toArray().Cast <string>());
            return(keywords.Distinct().OrderBy(k => k));
        }
示例#4
0
 public IEnumerable <string> GetStepKeywords(StepKeyword stepKeyword)
 {
     return(NativeLanguageService.keywords(stepKeyword.ToString().ToLowerInvariant()).toArray().Cast <string>());
 }