Example #1
0
        private IBook createBook(string title, params IParagraph[] paragraphs)
        {
            IParagraph p1 = new Paragraph(0, "P1");
            IParagraph p2 = new Paragraph(1, "P2");
            IParagraph p3 = new Paragraph(2, "P3");
            IParagraph p4 = new Paragraph(3, "P4");
            IParagraph p5 = new Paragraph(4, "P5");

            p1.AddAnswers(
                new Answer("Answer 1", 1),
                new Answer("Answer 2", 3));

            p2.AddAnswers(
                new Answer("Answer 3", 2),
                new Answer("Answer 4", 4));

            p3.AddAnswers(
                new Answer("Answer 5", 0),
                new Answer("Answer 6", 1),
                new Answer("Answer 7", 3));

            IBook book = new Book(title);

            book.AddParagraphs(p1, p2, p3, p4, p5);
            if (paragraphs != null)
            {
                book.AddParagraphs(paragraphs);
            }

            return(book);
        }
Example #2
0
        public void NextParagraphId()
        {
            IParagraph paragraph = new Paragraph(1, "Paragraph");

            paragraph.AddAnswers(
                new Answer("Answer 1", 1),
                new Answer("Answer 2", 2),
                new Answer("Answer 3", 3));

            Assert.AreEqual(-1, paragraph.NextParagraphId("A Answer"));

            Assert.AreEqual(2, paragraph.NextParagraphId("Answer 2"));
        }
Example #3
0
        public void IsTerminalTest()
        {
            IParagraph paragraph = new Paragraph(0, "Paragraph");

            Assert.IsTrue(paragraph.IsTerminal);

            paragraph.AddAnswers(
                new Answer("Answer 1", 1),
                new Answer("Answer 2", 2),
                new Answer("Answer 3", 3));

            Assert.IsFalse(paragraph.IsTerminal);
        }
Example #4
0
        public void AnswersTest()
        {
            IParagraph paragraph = new Paragraph(0, "Paragraph");

            paragraph.AddAnswers(
                new Answer("Answer 1", 1),
                new Answer("Answer 2", 2),
                new Answer("Answer 3", 3));

            IList <string> answers = new List <string>()
            {
                "Answer 1",
                "Answer 2",
                "Answer 3"
            };
            int i = 0;

            foreach (var answer in paragraph.Answers)
            {
                Assert.AreEqual(answer, answers[i]);
                i++;
            }
        }