Пример #1
0
        public IEnumerable <StringIntervalIndecies> ReplacementIndecies(string name)
        {
            var nameToAnalyze = searchCaseSensitive ? name : name.ToLower();

            var allIndecies = searchStrings.Select(search => IndexSearcher.GetReplacementIndexTuples(nameToAnalyze, search))
                              .SelectMany(indexList => indexList)
                              .OrderBy(tuple => tuple.StartIndex)
                              .ToList();

            int currentEnd = allIndecies[0].EndIndex;

            var resultList = new List <StringIntervalIndecies> {
                allIndecies[0]
            };

            for (int i = 1; i < allIndecies.Count; i++)
            {
                var item = allIndecies[i];
                if (item.StartIndex >= currentEnd)
                {
                    currentEnd = item.EndIndex;
                    resultList.Add(item);
                }
            }

            return(resultList);
        }
Пример #2
0
        public void IndexSearcherFindsOneIndexTuple(string name, string search, StringIntervalIndecies indexTuple)
        {
            IReadOnlyList <StringIntervalIndecies> resultList = IndexSearcher.GetReplacementIndexTuples(name, search).ToList();

            Assert.Equal(resultList.Count, 1);
            Assert.Equal(resultList[0], indexTuple);
        }
Пример #3
0
 public IEnumerable <StringIntervalIndecies> ReplacementIndecies(string name)
 {
     return(IndexSearcher.GetReplacementIndexTuples(name, " "));
 }
Пример #4
0
        public IEnumerable <StringIntervalIndecies> ReplacementIndecies(string name)
        {
            var nameToAnalyze = searchCaseSensitive ? name : name.ToLower();

            return(IndexSearcher.GetReplacementIndexTuples(nameToAnalyze, searchString));
        }
Пример #5
0
        public void IndexSearcherFindsNoIndexTuples(string name, string search)
        {
            var resultList = IndexSearcher.GetReplacementIndexTuples(name, search);

            Assert.Equal(resultList.Count(), 0);
        }