Example #1
0
        private void useGroupedSuggestionIfNeeded(List <Suggestion> results, Scope scope, Suggestion toReplace)
        {
            if (scope.VisitedByGroup)
            {
                Console.Write("break here");
            }
            if (/*!scope.VisitedByGroup && */ scope.Name != string.Empty && !(toReplace is GroupedSuggestionDecorator))
            {
                scope.VisitedByGroup = true;
                GroupedSuggestionDecorator groupedSug = null;
                groupedSug = new GroupedSuggestionDecorator(toReplace, scope);


                for (int i = 0; i < results.Count; i++)
                {
                    if (results[i] == toReplace)
                    {
                        results.Remove(toReplace);
                        results.Insert(i, groupedSug);
                    }
                    return;
                }
            }
            if ((toReplace is GroupedSuggestionDecorator))
            {
                ((GroupedSuggestionDecorator)toReplace).GroupName = scope.Name;
            }
        }
 public void GroupedSuggestion_Create_ContainsGoodRegex2()
 {
     Scope scope = new Scope("a", "Name");
     Suggestion s = new Suggestion(@"b", "desc");
     GroupedSuggestionDecorator decorator = new GroupedSuggestionDecorator(s, scope);
     Assert.AreEqual(@"(?<Name>b)", decorator.RegexText);
 }
 public void GroupedSuggestion_CreateWithNoScopeName_ReturnsOriginalRegex()
 {
     Scope unnamedScope = new Scope("a");
     Suggestion s = new Suggestion(@"a", "desc");
     GroupedSuggestionDecorator decorator = new GroupedSuggestionDecorator(s, unnamedScope);
     Assert.AreEqual(@"a", decorator.RegexText);
 }
        private void useGroupedSuggestionIfNeeded(List<Suggestion> results, Scope scope, Suggestion toReplace)
        {
            if (scope.VisitedByGroup)
            {
                Console.Write("break here");
            }
            if (/*!scope.VisitedByGroup && */scope.Name != string.Empty && !(toReplace is GroupedSuggestionDecorator))
            {
                scope.VisitedByGroup = true;
                GroupedSuggestionDecorator groupedSug = null;
                groupedSug = new GroupedSuggestionDecorator(toReplace, scope);

                for (int i = 0; i < results.Count; i++)
                {
                    if (results[i] == toReplace)
                    {
                        results.Remove(toReplace);
                        results.Insert(i, groupedSug);
                    }
                    return;
                }
            }
            if ((toReplace is GroupedSuggestionDecorator))
            {
                ((GroupedSuggestionDecorator)toReplace).GroupName = scope.Name;
            }
        }