Exemple #1
0
        public void CommaSeparatedSplitting_Works()
        {
            // arrange
            MockPartProcessor mockPartProcessor = new MockPartProcessor();
            string            toParse           = "Hello,World,!!!";

            Splitter sut = new Splitter(',');

            // act
            sut.ExtractParts(toParse, mockPartProcessor);

            // assert
            Assert.Equal(3, mockPartProcessor.Count);
        }
Exemple #2
0
        public void CommaSeparatedSplitting_ReturnsTailEnd_Works()
        {
            // arrange
            MockPartProcessor mockPartProcessor = new MockPartProcessor();
            string            toParse           = "Hello,World,!!!";

            Splitter sut = new Splitter(',');

            // act
            ReadOnlySpan <char> tail = sut.ExtractParts(toParse, mockPartProcessor, true);

            // assert
            Assert.Equal(2, mockPartProcessor.Count);
            Assert.True(tail.SequenceEqual("!!!"));
        }
        public void ParsingOnPool_Works()
        {
            // arrange
            string       toParse      = "Hello World !!!";
            MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(toParse));

            memoryStream.Seek(0, SeekOrigin.Begin);
            MockPartProcessor mockPartProcessor = new MockPartProcessor();

            StreamParser sut = new StreamParser(new Splitter(' '), Encoding.UTF8, 1024 * 1024);

            // act
            sut.ParseStream(memoryStream, mockPartProcessor);

            // assert
            Assert.Equal(3, mockPartProcessor.Count);
        }