Ejemplo n.º 1
0
        public void PoemSchemaGetLinesUnrecognizableSeparatorTest()
        {
            string separator = "?";
            PoemSchema poemSchema = new PoemSchema();
            string testSchema = String.Format("x--x-{0}-x--x{0}-x-", separator);
            poemSchema.Value = testSchema;
            string[] expectedLines = new string[] { "x--x-?-x--x?-x-" };

            string[] actualLines = poemSchema.GetLines();

            CollectionAssert.AreEqual(expectedLines, actualLines);
        }
Ejemplo n.º 2
0
        // Summary:
        //     Main method to generate a poem text by the poem schema and syntax rules.
        //
        // Parameters:
        //   schema:
        //     The schema object by which the poem should be constructed.
        //   document:
        //     The object which represents the syntax rules to build a poem.
        // Returns:
        //     The string containing the generated poem text. The line
        //     breaks separated by '\n' character.
        // Exceptions:
        //   System.ArgumentNullException:
        //     document is null.
        public string GeneratePoem(PoemSchema schema, IPoemSyntaxRuleDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document", "Argument cannot be null.");
            }

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

            foreach (string line in schema.GetLines())
            {
                string generatedLine = this.GeneratePoemLine(line, document);

                poemLines.Add(generatedLine);
            }

            return(string.Join("\n", poemLines));
        }