Пример #1
0
        public void CreateANewForm()
        {
            // Act
            Form f1 = SetupForm();
            Form f2 = FormEngine.CreateForm("B");

            // Assert
            Assert.IsNotNull(f1);
            Assert.AreNotSame(f1, f2);
        }
Пример #2
0
        public void CreateAFormWithQFreeText()
        {
            Form       f  = FormEngine.CreateForm("Test");
            QComposite n1 = f.Questions.AddANewQuestion <QComposite>("Informations sur le programme", false);
            QFreeText  q1 = n1.AddANewQuestion <QFreeText>("Qu'aimez-vous dans ce programme ?", true);
            QFreeText  q2 = (QFreeText)n1.AddANewQuestion("DynamicForms.Components.QFreeText, DynamicForms.Components", "Qu'est-ce qui marche particulièrement bien ?", false);
            QFreeText  q3 = (QFreeText)n1.AddANewQuestion("DynamicForms.Components.QFreeText, DynamicForms.Components", "Dans quelle application l'utiliserez-vous ?", true);
            QComposite n2 = f.Questions.AddANewQuestion <QComposite>("Informations sur l'utilisation", false);
            QFreeText  q4 = n2.AddANewQuestion <QFreeText>("Qu'est-ce qui est simple à utiliser pour vous ?", true);
            QFreeText  q5 = n2.AddANewQuestion <QFreeText>("Comment l'utilisez-vous ?", false);

            AnswerSheet toto = f.FindOrCreateAnswerSheetFor("Toto");
            AFreeText   a1   = (AFreeText)toto.CreateAnswerFor(q1);

            a1.AllowEmptyAnswer = false;
            a1.FreeTextAnswer   = "Une réponse de test 1";
            AFreeText a2 = (AFreeText)toto.CreateAnswerFor(q2);

            a2.AllowEmptyAnswer = true;
            a2.FreeTextAnswer   = "Une réponse de test 2";
            AFreeText a3 = (AFreeText)toto.CreateAnswerFor(q3);

            a3.AllowEmptyAnswer = false;
            a3.FreeTextAnswer   = "Une réponse de test 3";
            AFreeText a4 = (AFreeText)toto.CreateAnswerFor(q4);

            a4.AllowEmptyAnswer = true;
            a4.FreeTextAnswer   = "";
            AFreeText a5 = (AFreeText)toto.CreateAnswerFor(q5);

            a5.AllowEmptyAnswer = false;
            a5.FreeTextAnswer   = "Une réponse de test 5";
            AFreeText a6 = (AFreeText)toto.CreateAnswerFor(q5);

            a6.AllowEmptyAnswer = false;
            a6.FreeTextAnswer   = " ";
            a6.Accept(new RequirementValidator());

            Assert.AreEqual(3, n1.Children.Count);
            Assert.AreEqual(2, n2.Children.Count);
            Assert.AreSame(q2.Parent, n1);
            Assert.AreSame(q4.Parent, n2);
            Assert.AreSame(toto.Answers[q1], a1);
            Assert.AreSame(toto.Answers[q5], a6);
            Assert.Throws <NotSupportedException>(delegate { toto.CreateAnswerFor(n1); });
        }
Пример #3
0
 private Form SetupForm()
 {
     return(FormEngine.CreateForm("A"));
 }