public void StylesAtPageLevelTest()
        {
            QLSNode node = QLSParserHelper.Parse(PageStylesDefaultsRaw);

            Assert.AreEqual(1, node.Children.Count);
            Assert.AreEqual(2, node.Children[0].NodeStyles[0].StylingValues.Count);
        }
        public void PageNameTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyle);

            Assert.AreEqual("FirstPage", qls.Children[0].ID);
            Assert.AreEqual(QLSNodeType.Page, qls.Children[0].NodeType);
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("---- Start parsing the QL ----");
            FormNode ql = QLParserHelper.Parse(Util.FileToString(QLFile));

            QLPrinter.Print(ql);

            Console.WriteLine();
            Console.WriteLine("---- Start parsing QLS ----");
            QLSNode qls = QLSParserHelper.Parse(Util.FileToString(QLSFile));

            QLSPrinter.Print(qls);

            Analyser.Analyse(ql, qls);

            var errors = Analyser.GetErrors();

            Console.WriteLine("\n\n---- Errors and/or warnings: {0} ----", errors.Count);
            foreach (string error in errors)
            {
                Console.WriteLine(error);
            }

            Console.ReadLine();
        }
        public void SectionNameTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyle);

            Assert.AreEqual("SectionOne", qls.Children[0].Children[0].ID);
            Assert.AreEqual(QLSNodeType.Section, qls.Children[0].Children[0].NodeType);
        }
        public void QuestionIdentifierTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyle);

            Assert.AreEqual("hasSoldHouse", qls.Children[0].Children[0].Children[0].ID);
            Assert.AreEqual(QLSNodeType.Question, qls.Children[0].Children[0].Children[0].NodeType);
        }
        public void StylesheetNameTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyle);

            Assert.AreEqual("TestForm", qls.ID);
            Assert.AreEqual(QLSNodeType.Stylesheet, qls.NodeType);
        }
        public void StyleInSectionTest()
        {
            QLSNode node = QLSParserHelper.Parse(SectionDefaultsRaw);

            Assert.AreEqual(1, node.Children.Count);
            Assert.AreEqual(1, node.Children[0].Children.Count);
            Assert.AreEqual(2, node.Children[0].Children[0].NodeStyles[0].StylingValues.Count);
        }
Example #8
0
        public void SimpleWithoutDuplicateQLSTest()
        {
            QLSNode node     = QLSParserHelper.Parse(simpleWithoutDuplicateQLS);
            var     analyser = new DuplicateIdentifiersAnalyser();
            var     result   = analyser.Analyse(node);

            Assert.IsTrue(result);
        }
        public void MultipleDefaultStylesTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyleWithMultipleDefaults);

            var styles = qls.Children[0].Children[0].NodeStyles;

            Assert.AreEqual(2, styles.Count);
        }
Example #10
0
        public void MultipleStylesAtStylesheetLevelTest()
        {
            QLSNode node = QLSParserHelper.Parse(StyleSheetMultipleDefaultsRaw);

            Assert.AreEqual(1, node.Children.Count);
            Assert.AreEqual(2, node.NodeStyles[0].StylingValues.Count);
            Assert.AreEqual(3, node.NodeStyles[1].StylingValues.Count);
        }
        public void UnknownIdentifierWithTypoTests()
        {
            SymbolTable.Add("soldHouseIn2010", QValueType.Boolean);
            QLSNode node     = QLSParserHelper.Parse(simpleWithTypoInQLS);
            var     analyser = new UnknownIdentifiersAnalyser();
            var     isValid  = analyser.Analyse(node);

            Assert.IsFalse(isValid);
        }
        public void WidgetStyleTextfieldTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyleWithWidgetTypeTextfield);

            var questionNode = qls.Children[0].Children[0].Children[0];

            Assert.AreEqual(WidgetType.Textfield, questionNode.NodeStyles[0].WidgetSpecification.WidgetType);
            Assert.AreEqual(0, questionNode.NodeStyles[0].WidgetSpecification.WidgetTypeArguments.Count);
        }
Example #13
0
        public void NoIdentifiersAreUsed()
        {
            SymbolTable.Add("soldHouseIn2010", QValueType.Boolean);
            QLSNode node     = QLSParserHelper.Parse(simpleWithouIdentifiersQLS);
            var     analyser = new AllIdentifiersAreUsedAnalyser();
            var     result   = analyser.Analyse(node);

            Assert.IsFalse(result);
        }
        public void WidgetStyleArgumentsTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyleWithWidgetTypeWithArguments);

            var questionNode = qls.Children[0].Children[0].Children[0];

            Assert.AreEqual(WidgetType.Radio, questionNode.NodeStyles[0].WidgetSpecification.WidgetType);
            Assert.AreEqual(3, questionNode.NodeStyles[0].WidgetSpecification.WidgetTypeArguments.Count);
            Assert.AreEqual("Yes", questionNode.NodeStyles[0].WidgetSpecification.WidgetTypeArguments[0]);
            Assert.AreEqual("No", questionNode.NodeStyles[0].WidgetSpecification.WidgetTypeArguments[1]);
            Assert.AreEqual("Maybe", questionNode.NodeStyles[0].WidgetSpecification.WidgetTypeArguments[2]);
        }
        public void DefaultStylesTest()
        {
            QLSNode qls = QLSParserHelper.Parse(SimpleStyleWithDefaults);

            var styles = qls.Children[0].Children[0].NodeStyles;

            Assert.AreEqual("width", styles[0].StylingValues[0].StyleProperty);
            Assert.AreEqual(QValueType.Integer, styles[0].StylingValues[0].QValueType);
            Assert.AreEqual("100", styles[0].StylingValues[0].StyleValue);

            Assert.AreEqual("fontSize", styles[0].StylingValues[1].StyleProperty);
            Assert.AreEqual(QValueType.Double, styles[0].StylingValues[1].QValueType);
            Assert.AreEqual("12.5", styles[0].StylingValues[1].StyleValue);
        }
Example #16
0
        private FormManager QLQLS(string rawQl, string rawQls, ElementManagerController elementManagerController, ref List <string> errors)
        {
            FormNode formNode = QLParserHelper.Parse(rawQl);
            QLSNode  qlsNode  = QLSParserHelper.Parse(rawQls);

            if (!Analyser.Analyse(formNode, qlsNode))
            {
                errors.AddRange(Analyser.GetErrors());
                return(null);
            }

            FormManager result = ElementManagerFactory.CreateForm(formNode, elementManagerController);

            result = ElementManagerFactory.ApplyQLS(result, qlsNode, elementManagerController, ref errors);
            return(result);
        }