public void SaveLearnedData(string configDir)
        {
            var valueStore   = new ValueStore();
            var stepDefStore = new StepDefStore(valueStore);

            foreach (var stepDefRegex in _stepDefRegexes)
            {
                var paramNames = stepDefRegex.Key.GetValidNames();
                for (int paramNumber = 0; paramNumber < paramNames.Count; paramNumber++)
                {
                    var group    = new ValueStoreGroup(paramNames[paramNumber]);
                    var tmpItems = new HashSet <ValueStoreItem>(ValueStoreItem.RuValueComparer);
                    foreach (var gherkinStep in stepDefRegex.Value)
                    {
                        var item = ValueStoreItem.FromMacros(gherkinStep.Text, paramNumber);
                        if (item == default(ValueStoreItem))
                        {
                            continue;
                        }
                        if (!tmpItems.Contains(item))
                        {
                            tmpItems.Add(item);
                        }
                    }
                    group.Items.AddRange(tmpItems.ToList());
                    valueStore.AddGroup(group);
                    stepDefStore.AddStepDef(stepDefRegex.Key);
                }
            }
            valueStore.Save(ValueStoreConfigsDir, "learned");
            stepDefStore.Save(StepDefStoreConfigsDir, "learned");
        }
예제 #2
0
        public static ValueStoreItem FromMacros(string stepLineText, int paramNumber)
        {
            var match = _macrosRegex.Match(stepLineText);

            if (match.Success && paramNumber < match.Groups.Count)
            {
                var macrosValue = match.Groups[1 + paramNumber].Value;
                var ruMach      = _ruRegex.Match(macrosValue);
                var enMach      = _enRegex.Match(macrosValue);
                if (ruMach.Groups.Count == 2 && enMach.Groups.Count == 2)
                {
                    var res = new ValueStoreItem(enMach.Groups[1].Value, ruMach.Groups[1].Value);
                    return(res);
                }
            }
            return(new ValueStoreItem(string.Empty));
        }
예제 #3
0
 public bool Equals(ValueStoreItem other)
 {
     return(string.Equals(_ruRu, other._ruRu));
 }