Beispiel #1
0
        private bool GetTagValue <T>(TestClassGenerationContext generationContext, Scenario scenario, string retryTag, TryParseDelegate <T> parser, out T value)
        {
            value = default(T);
            var tagNames = scenario.Tags != null?scenario.Tags.Select(_ => _.Name) : new string[0];

            string retryCountValue;

            return(tagFilterMatcher.GetTagValue(retryTag, tagNames, out retryCountValue) &&
                   parser(retryCountValue, out value) ||
                   tagFilterMatcher.GetTagValue(retryTag, generationContext.Feature, out retryCountValue) &&
                   parser(retryCountValue, out value));
        }
        private bool GetTagValue <T>(TestClassGenerationContext generationContext, ScenarioOutline scenarioOutline, string retryTag, TryParseDelegate <T> parser, out T value)
        {
            value = default(T);
            var tagNames = scenarioOutline.Tags?.Select(_ => _.GetNameWithoutAt()) ?? new string[0];

            tagNames = tagNames.ToList();
            string retryCountValue;

            return(tagFilterMatcher.GetTagValue(retryTag, tagNames, out retryCountValue) &&
                   parser(retryCountValue, out value) ||
                   tagFilterMatcher.GetTagValue(retryTag, generationContext.Document, out retryCountValue) &&
                   parser(retryCountValue, out value));
        }
Beispiel #3
0
        public static bool GetTagValue(this ITagFilterMatcher tagFilterMatcher, string tagFilter, Feature feature, out string value)
        {
            if (feature.Tags == null)
            {
                value = null;
                return(false);
            }

            return(tagFilterMatcher.GetTagValue(tagFilter, feature.Tags.Select(t => t.Name), out value));
        }
        public SpecFlowDocument PatchDocument(SpecFlowDocument originalSpecFlowDocument)
        {
            var feature             = originalSpecFlowDocument.SpecFlowFeature;
            var scenarioDefinitions = feature.Children.Where(c => c is Background).ToList();

            foreach (var scenario in feature.ScenarioDefinitions.OfType <Scenario>())
            {
                if (!_tagFilterMatcher.GetTagValue(PROPERTY_TAG, scenario.Tags.Select(t => t.Name.Substring(1)),
                                                   out var tagString))
                {
                    scenarioDefinitions.Add(scenario);
                    continue;
                }

                var newScenarioOutline = PatchScenario(tagString, scenario);

                scenarioDefinitions.Add(newScenarioOutline);
            }

            var newDocument = CreateSpecFlowDocument(originalSpecFlowDocument, feature, scenarioDefinitions);

            return(newDocument);
        }
 public static bool GetTagValue(this ITagFilterMatcher tagFilterMatcher, string tagFilter, SpecFlowDocument document, out string value)
 {
     return(tagFilterMatcher.GetTagValue(tagFilter, document.SpecFlowFeature.Tags.Select(t => t.GetNameWithoutAt()), out value));
 }