Beispiel #1
0
        public void TestCreateQuestion()
        {
            Question testQ = new QuestionBool(TestQuestionId, TestQuestionLabel);

            Assert.AreEqual(TestQuestionId, testQ.Id);
            Assert.AreEqual(TestQuestionLabel, testQ.Label);
        }
Beispiel #2
0
        public void TestAddQuestionToForm()
        {
            Question        testQ     = new QuestionBool(TestQuestionId, TestQuestionLabel);
            List <Question> questions = new List <Question>()
            {
                testQ
            };
            QuestionForm testF = new QuestionForm(TestFormId, questions);

            Assert.IsNotNull(testF.Questions);
            Assert.AreEqual(1, testF.Questions.Count);
            Assert.AreSame(testQ, testF.Questions[0]);
        }
Beispiel #3
0
        public void Visit(QuestionBool question)
        {
            if (question.Condition?.Evaluate() == false)
            {
                return;
            }
            var checkbox = new CheckBox
            {
                Text     = question.Label,
                AutoSize = true,
                Checked  = question.Value,
                Enabled  = !question.Computed
            };

            if (!question.Computed)
            {
                checkbox.CheckedChanged += (sender, e) =>
                {
                    question.Value = ((CheckBox)sender).Checked;
                    UpdateControls();
                };
            }
            Panel.Controls.Add(checkbox);
        }