public void Create_GlobalTable_TestInput() { GlobalTable globalTable = new GlobalTable(); TextInputSymbol textInputSymbol = new TextInputSymbol(new ErrorReport(), "@authorName", "Author Name", "Description", "Rob Blake", true); List <BaseFunction> functionArguments = new List <BaseFunction> { new VariableFunction(new FuncInfo("stub", 1, 1), globalTable, "@authorName") }; ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@upperAuthorName", "Upper Author Name", "Description", true, true, new UpperCaseFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); globalTable.AddSymbol(textInputSymbol); globalTable.AddSymbol(expressionSymbol); string textOutput_A = globalTable.GetValueOfSymbol("@authorName"); string exprOutput_A = globalTable.GetValueOfSymbol("@upperAuthorName"); globalTable.Input("@authorName", "John Doe"); string textOutput_B = globalTable.GetValueOfSymbol("@authorName"); string exprOutput_B = globalTable.GetValueOfSymbol("@upperAuthorName"); Assert.AreEqual("Rob Blake", textOutput_A); Assert.AreEqual("ROB BLAKE", exprOutput_A); Assert.AreEqual("John Doe", textOutput_B); Assert.AreEqual("JOHN DOE", exprOutput_B); }
public void IfDecissionFunction_GivenSelectedOption_ReturnsCorrectValue() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); OptionInputSymbol optionInputSymbol = new OptionInputSymbol(new ErrorReport(), "@databaseOptions", "Database Options", "Description", "ADVWORKS"); optionInputSymbol.AddOption("ADVWORKS", "Adventure Works Database"); optionInputSymbol.AddOption("PUBBOOKS", "Published Books Database"); IfDecissionFunction decissionFunc = new IfDecissionFunction(new FuncInfo("stub", 1, 1), globalTable, "@databaseOptions"); decissionFunc.AddFunction("ADVWORKS", new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "You chose DM")); decissionFunc.AddFunction("PUBBOOKS", new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "You chose Published Books Database")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@selectedDatabase", "Selected Database", "Description", true, true, decissionFunc); globalTable.AddSymbol(optionInputSymbol); globalTable.AddSymbol(expressionSymbol); Assert.AreEqual("ADVWORKS", globalTable.GetValueOfSymbol("@databaseOptions")); Assert.AreEqual("You chose DM", globalTable.GetValueOfSymbol("@selectedDatabase")); globalTable.Input("@databaseOptions", "1"); Assert.IsTrue(expressionSymbol.IsPlaceholder); Assert.IsTrue(expressionSymbol.IsVisibleToEditor); Assert.AreEqual("PUBBOOKS", globalTable.GetValueOfSymbol("@databaseOptions")); Assert.AreEqual("You chose Published Books Database", globalTable.GetValueOfSymbol("@selectedDatabase")); }
public override string VisitTextBox(QikTemplateParser.TextBoxContext context) { string controlId = context.VARIABLE().GetText(); SymbolArguments symbolArguments = new SymbolArguments(errorReport); symbolArguments.Process(context.declArgs()); TextInputSymbol textInputSymbol = new TextInputSymbol(errorReport, controlId, symbolArguments.Title, symbolArguments.Description, symbolArguments.Default, symbolArguments.IsPlaceholder); scopeTable.AddSymbol(textInputSymbol); return(base.VisitTextBox(context)); }
public void CreateFieldInput(string symbol, string fieldName, string description) { HasErrors = false; AutoInputSymbol autoInputSymbol = new AutoInputSymbol(this.errorReport, symbol, fieldName, description); if (!scopeTable.Symbols.Contains(autoInputSymbol.Symbol)) { scopeTable.AddSymbol(autoInputSymbol); } }
public void Placeholder_NotAvailable_When_IsPlaceholder_False() { GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "dd/MM/yyyy")); CurrentDateFunction currentDateFunction = new CurrentDateFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments); UpperCaseFunction upperCaseFunction = new UpperCaseFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments); ExpressionSymbol expressionSymbol1 = new ExpressionSymbol(new ErrorReport(), "@currentDate", "Current Date", "Description", false, true, currentDateFunction); ExpressionSymbol expressionSymbol2 = new ExpressionSymbol(new ErrorReport(), "@camelCase", "Camel Cased", "Description", true, true, upperCaseFunction); globalTable.AddSymbol(expressionSymbol1); globalTable.AddSymbol(expressionSymbol2); Assert.AreEqual(1, globalTable.Placeholders.Length); Assert.AreEqual("@{camelCase}", globalTable.Placeholders[0]); Assert.AreEqual("DD/MM/YYYY", globalTable.GetValueOfSymbol("@camelCase")); }