public ICollection <Sentence> Parse(string text)
        {
            var sentences = new List <Sentence>();

            foreach (var rawSentence in rawSentencesParser.Parse(text))
            {
                var words = wordsParser.Parse(rawSentence);

                sentences.Add(words.ToSentence());
            }

            return(sentences);
        }
Beispiel #2
0
        public void WhenNonEmptyText_Parse_ShouldReturnOrderedWords()
        {
            //arrange
            rawSentencesParser.Parse(Arg.Any <string>()).Returns(new string[] { "sentence 1", "sentence 2" });
            wordsParser.Parse(Arg.Any <string>()).Returns(new string[] { "zebra", "lion", "elephant" });
            var expectedWordsOrder = new string[] { "elephant", "lion", "zebra" };

            //act
            var sentences = sentencesParser.Parse("random text");

            //assert
            sentences.Should().HaveCount(2);
            sentences.ElementAt(0).Words.Should().BeEquivalentTo(expectedWordsOrder);
        }