コード例 #1
0
        public void simple_paragraph_few_sentences_returns_everything()
        {
            var stringb = new StringBuilder();

            for (int i = 0; i < TextSamples.SimpleTextGenerator.NUM_SENTENCES_IN_A_PARAGRAPH - 1; i++)
            {
                stringb.AppendFormat("This is a test sentence - {0}. ", i.ToString());
            }

            var simple = new SimpleTextGenerator(stringb.ToString());

            Assert.That(simple.GetParagraph().GetText(), Is.EqualTo(stringb.ToString().Trim()));
        }
コード例 #2
0
        public void simple_paragraph_complex_paragraph()
        {
            List <string> allSentences = new List <string>();
            var           stringb      = new StringBuilder();

            for (int i = 0; i < 10; i++)
            {
                string sample = string.Format("This is a test sentence - {0}. ", i.ToString());
                stringb.Append(sample);
                allSentences.Add(sample);
            }

            List <string> possibilities = new List <string>();

            for (int i = 0; i <= allSentences.Count - SimpleTextGenerator.NUM_SENTENCES_IN_A_PARAGRAPH; i++)
            {
                possibilities.Add(string.Join("", allSentences.Skip(i).Take(SimpleTextGenerator.NUM_SENTENCES_IN_A_PARAGRAPH)).Trim());
            }

            var    simple    = new SimpleTextGenerator(stringb.ToString());
            string paragraph = simple.GetParagraph().GetText();

            Assert.That(paragraph, Is.AnyOf(possibilities.ToArray()));
        }