Пример #1
0
        public void ParseSimpleStylesheetWithOnePageOneSectionOneQuestion_WillSucceed()
        {
            var  stylesheetTask = new StylesheetTask(TestDataResolver.LoadTestFile("onePageStylesheetWithQuestion.qls"), new SymbolTable());
            Node ast            = _parsingService.Process(stylesheetTask).Ast;

            _assertVisitor.EnqueueStylesheetNodeCallback(st =>
            {
                Assert.AreEqual("test", st.Label);
            });
            _assertVisitor.EnqueuePageNodeCallback(p =>
            {
                Assert.AreEqual("testPage", p.Label);
            });
            _assertVisitor.EnqueueQuestionNodeCallback(q =>
            {
                Assert.AreEqual("questionOne", q.Label);
            });
            ast.Accept(_assertVisitor);
            _assertVisitor.VerifyAll();
        }
Пример #2
0
        public void ParseOneQuestionWithALabelNoConditional_WillSucceed()
        {
            // Arrange & Act
            var task = _parsingPipeline.Process(new ParsingTask(TestDataResolver.LoadTestFile("singleQuestion.ql")));

            // Assert
            _assertVisitor.EnqueueQuestionNodeCallback(question =>
            {
                Assert.AreEqual("whatIsMeaning", question.Label);
                Assert.AreEqual("What is the meaning of life?", question.Description);
                Assert.AreEqual(QLType.Decimal, question.Type);
            });
            task.Ast.Accept(_assertVisitor);
            _assertVisitor.VerifyAll();
        }
Пример #3
0
        public void OneConditionalAssignment_WillRemoveTheIfBlock()
        {
            // Arrange
            var         parsingTask = new ParsingTask(TestDataResolver.LoadTestFile("oneConditional.ql"));
            ParsingTask taskOutput  = _parsingPipeline.Process(parsingTask);
            var         newAst      = _interpreter.EvaluateAst(parsingTask.Ast, _memory, parsingTask.SymbolTable);

            _assertVisitor.EnqueueQuestionNodeCallback(q =>
            {
                Assert.AreEqual("elseQuestion", q.Description);
            });

            // Act
            newAst.Accept(_assertVisitor);

            // Verify
            _assertVisitor.VerifyAll();
        }