コード例 #1
0
        public StringCompareResult Get(string inputText, string subText)
        {
            var returnResult = new StringCompareResult()
            {
                IsValid = true, Description = new List <string>()
            };

            returnResult = _stringComparerService.ValidateInputString(inputText, subText);

            if (returnResult.IsValid)
            {
                var indices = _stringComparerService.GetAllIndicesOf(subText, inputText);
                if (indices.Any())
                {
                    returnResult.Description.AddRange(indices);
                }
                else
                {
                    returnResult.IsValid = false;
                    returnResult.Description.Add("No matching text found.");
                }
            }

            return(returnResult);
        }
コード例 #2
0
        public void ShouldReturnIndexIfFound(string inputText, string subText, int numberOfIndices)
        {
            var result = _stringComparerService.GetAllIndicesOf(subText, inputText);

            Assert.AreEqual(numberOfIndices, result.Count());
        }