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 void UpdateIndicator(int index, string name, string equation, string format) { DataRow row = GlobalRow; if (name != null) { row["Indicator" + index.ToString() + "Name"] = name; } else { row["Indicator" + index.ToString() + "Name"] = DBNull.Value; } if (equation != null) { row["Indicator" + index.ToString() + "Equation"] = equation; } else { row["Indicator" + index.ToString() + "Equation"] = DBNull.Value; } if (format != null) { row["Indicator" + index.ToString() + "Format"] = format; } else { row["Indicator" + index.ToString() + "Format"] = DBNull.Value; } GlobalTable.AcceptChanges(); }
internal BaseFunction(FuncInfo funcInfo, GlobalTable scopeTable) { this.Line = funcInfo.Line; this.Column = funcInfo.Column; this.Name = funcInfo.Name; this.scopeTable = scopeTable; this.functionArguments = new List <BaseFunction>(); }
private void UpdateGlobalConfigTable(bool update_version) { DataRow row = GlobalRow; row["Version"] = update_version ? Config.Local.CurrentVersion : "0.0.0.0"; GlobalTable.AcceptChanges(); }
public void Update() { // check if data-base is already up-to-date. if (HistoryTable.Rows.Count > 0 && GlobalTable.Rows.Count > 0 && GlobalTable.Rows[0]["LastUpdate"] != DBNull.Value && ((DateTime)GlobalTable.Rows[0]["LastUpdate"]).ToShortDateString() == DateTime.Now.ToShortDateString()) { return; } // get stock's option list ArrayList list = null; // clear data-set Clear(); list = Comm.Server.GetHistoricalData(symbol, DateTime.Now.AddYears(-2), DateTime.Now); if (list == null || list.Count == 0) { return; } // begin updating data HistoryTable.BeginLoadData(); GlobalTable.BeginLoadData(); // clear data-set Clear(); foreach (History history in list) { // add option to table AddHistoryEntry(history); } // update time-stamp DataRow row = GlobalTable.NewRow(); row["Symbol"] = symbol; row["LastUpdate"] = DateTime.Now; GlobalTable.Rows.Add(row); // accept changes GlobalTable.AcceptChanges(); HistoryTable.AcceptChanges(); // end updating data GlobalTable.EndLoadData(); HistoryTable.EndLoadData(); // save history data-base Save(); }
public void RemovePunctuationFunction_InputPunctuatedText_OutputPunctuationRemoved_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "LITERAL?!..TEXT.")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@removePunctuation", "Remove Punctuation Function", "Remove Punctuation Function", true, true, new RemovePunctuationFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); Assert.AreEqual("@removePunctuation", expressionSymbol.Symbol); Assert.AreEqual("@{removePunctuation}", expressionSymbol.Placeholder); Assert.AreEqual("Remove Punctuation Function", expressionSymbol.Title); Assert.AreEqual("LITERALTEXT", expressionSymbol.Value); }
public void CamelCaseFunction_InputPascalCase_OutputsCamelCase_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "LiteralText")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@classInstance", "Class Instance", "Description", true, true, new CamelCaseFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); Assert.AreEqual("@classInstance", expressionSymbol.Symbol); Assert.AreEqual("@{classInstance}", expressionSymbol.Placeholder); Assert.AreEqual("Class Instance", expressionSymbol.Title); Assert.AreEqual("literalText", expressionSymbol.Value); }
public void ProperCaseFunction_InputUpperCase_OutputsProperCase_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "LITERAL TEXT")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@toProperCase", "Proper Case Function", "Proper Case Function", true, true, new ProperCaseFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); Assert.AreEqual("@toProperCase", expressionSymbol.Symbol); Assert.AreEqual("@{toProperCase}", expressionSymbol.Placeholder); Assert.AreEqual("Proper Case Function", expressionSymbol.Title); Assert.AreEqual("Literal Text", expressionSymbol.Value); }
public IActionResult Index() { //date range to search in (yyyy,m,d) DateTime startDate = new DateTime(1920, 1, 1); DateTime endDate = new DateTime(1960, 1, 1); //create a connection to the database DataBase db = new DataBase(); //get the data for the global table List <GlobalData> globalData = GlobalTable.processGlobalData(db, startDate, endDate); db.CloseDataBase(); SearchModel model = new SearchModel(); model.SearchTerms = ""; model.globalData = globalData; return(View(model)); }
public void ConcatenateFunction_Input3Strings_ConcatenatesToSingleString_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); ConcatenateFunction concatFunc = new ConcatenateFunction(new FuncInfo("stub", 1, 1), globalTable); concatFunc.AddFunction(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "hello")); concatFunc.AddFunction(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, " ")); concatFunc.AddFunction(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "world")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@concat", "Concatenated String", "Description", true, true, concatFunc); Assert.AreEqual("@concat", expressionSymbol.Symbol); Assert.AreEqual("@{concat}", expressionSymbol.Placeholder); Assert.AreEqual("Concatenated String", expressionSymbol.Title); Assert.AreEqual("hello world", expressionSymbol.Value); }
public void CurrentDateFunction_RequestDate_ReturnsCurrentDate_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "dd/MM/yyyy")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@currentDate", "Current Date", "Description", true, true, new CurrentDateFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); Assert.AreEqual("@currentDate", expressionSymbol.Symbol); Assert.AreEqual("@{currentDate}", expressionSymbol.Placeholder); Assert.AreEqual("Current Date", expressionSymbol.Title); DateTime dateTime = DateTime.Now; Assert.AreEqual(DateTime.Now.ToString("dd/MM/yyyy"), expressionSymbol.Value); }
public void ReplaceFunction_InputText_ReplacesCorrectly_1() { // BEFORE REMOVING THIS TEST METHOD YOU NEED TO WRITE TESTS FOR ALL ITS POSSIBILITIES IN THE NEW STYLE BELOW GlobalTable globalTable = new GlobalTable(); List <BaseFunction> functionArguments = new List <BaseFunction>(); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "Dashboard Usage")); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, " ")); functionArguments.Add(new TextFunction(new FuncInfo("stub", 1, 1), globalTable, "_")); ExpressionSymbol expressionSymbol = new ExpressionSymbol(new ErrorReport(), "@classInstance", "Class Instance", "Description", true, true, new ReplaceFunction(new FuncInfo("stub", 1, 1), globalTable, functionArguments)); Assert.AreEqual("@classInstance", expressionSymbol.Symbol); Assert.AreEqual("@{classInstance}", expressionSymbol.Placeholder); Assert.AreEqual("Class Instance", expressionSymbol.Title); Assert.AreEqual("Dashboard_Usage", expressionSymbol.Value); }
public IActionResult DateChange(string terms) { //parse the string into it's values --- format (1492:2020) string[] splitTerms = terms.Split(":"); Console.WriteLine("Year range: " + splitTerms[0] + " -to- " + splitTerms[1]); //date range to search in (yyyy,m,d) DateTime startDate = new DateTime(Int32.Parse(splitTerms[0]), 1, 1); DateTime endDate = new DateTime(Int32.Parse(splitTerms[1]), 1, 1); //create a connection to the database DataBase db = new DataBase(); //get the data for the global table List <GlobalData> globalData = GlobalTable.processGlobalData(db, startDate, endDate); db.CloseDataBase(); return(new JsonResult(globalData)); }
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")); }
internal UserInputVisitor(GlobalTable scopeTable, IErrorReport errorReport) { this.scopeTable = scopeTable; this.errorReport = errorReport; }
public IntegerFunction(FuncInfo funcInfo, GlobalTable scopeTable, string text) : base(funcInfo, scopeTable) { this.text = text; }
internal TextFunction(FuncInfo funcInfo, GlobalTable scopeTable, string text) : base(funcInfo, scopeTable) { this.text = text; }
public PadLeftFunction(FuncInfo funcInfo, GlobalTable scopeTable, List <BaseFunction> functionArguments) : base(funcInfo, scopeTable, functionArguments) { }
public VariableFunction(FuncInfo funcInfo, GlobalTable scopeTable, string symbol) : base(funcInfo, scopeTable) { this.symbol = symbol; }
internal CurrentDateFunction(FuncInfo funcInfo, GlobalTable scopeTable, List <BaseFunction> functionArguments) : base(funcInfo, scopeTable, functionArguments) { }
internal IfDecissionFunction(FuncInfo funcInfo, GlobalTable scopeTable, string symbol) : base(funcInfo, scopeTable) { this.symbol = symbol; this.scopeTable = scopeTable; }
internal ConcatenateFunction(FuncInfo funcInfo, GlobalTable scopeTable) : base(funcInfo, scopeTable) { this.scopeTable = scopeTable; }
public static void Main(string[] args) { Config.load(); Console.Title = "PointBlank Server Auth"; CLogger.getInstance().form(); GlobalConsole.Load(); GlobalTable.Load(); GlobalDate.Load(); GlobalNetwork.Load(); while (true) { Thread.Sleep(200); Console.Write("> "); try { string command = Console.ReadLine(); switch (command) { case "stop": case "close": case "exit": { CLogger.getInstance().write(command); CLogger.getInstance().red("END OF LOG"); Thread.Sleep(200); Process.GetCurrentProcess().CloseMainWindow(); break; } case "reload shop": { CLogger.getInstance().write(command); CLogger.getInstance().debug("[Reload] ShopManager"); ShopInfoManager.getInstance(); Console.ResetColor(); break; } case "clear": { Console.Clear(); break; } case "help": { CLogger.getInstance().write(command); CLogger.getInstance().cyan("Help Command: "); CLogger.getInstance().debug("* stop / close / exit - Close Server."); CLogger.getInstance().debug("* reload shop - Reload Shop."); CLogger.getInstance().debug("* clear - Clear Console"); CLogger.getInstance().debug("* restart - Restart Server."); Console.ResetColor(); break; } case "restart": { var location = Assembly.GetExecutingAssembly().Location; Process.Start(location); Environment.Exit(0); break; } default: { CLogger.getInstance().write(command); CLogger.getInstance().warning("Invalid command!"); break; } } } catch { } } }
public RemovePunctuationFunction(FuncInfo funcInfo, GlobalTable scopeTable, List <BaseFunction> functionArguments) : base(funcInfo, scopeTable, functionArguments) { }
public HtmlEncodeFunction(FuncInfo funcInfo, GlobalTable scopeTable, List <BaseFunction> functionArguments) : base(funcInfo, scopeTable, functionArguments) { }