Beispiel #1
0
        protected IEnumerable <TreeNode> CreateChunkedNodesFromString(string text, int charsPerLine = 100)
        {
            var chunkDefinitions = StringChunker.ComputeChunksWithMinCharLimit(text, charsPerLine);

            foreach (var chunkDef in chunkDefinitions)
            {
                var messageChunk = text.Substring(chunkDef.StartPosition, chunkDef.ChunkLength);
                yield return(CreateNode(messageChunk));
            }
        }
Beispiel #2
0
        public void itShouldNotBreakWords1()
        {
            var charsPerChunk = 2;
            var input         = "abc def";

            var result = StringChunker.ComputeChunksWithMinCharLimit(input, charsPerChunk);

            Assert.AreEqual(2, result.Count);
            foreach (var chunk in result)
            {
                var chunked = input.Substring(chunk.StartPosition, chunk.ChunkLength);
            }
        }