public void ExecuteDropHelp() { String expected = "Drop tbName |-> Drop table from current db"; String actual = DbInterpretter.Execute("drop -h"); Assert.AreEqual(expected, actual); }
public void ExecuteCreateHelp() { String expected = "Create <table> (<field names>) |-> Create a table on current db"; String actual = DbInterpretter.Execute("create -h"); Assert.AreEqual(expected, actual); }
public void ExecuteUseHelp() { String expected = "Use DBname |-> Set the DBname database active (as empty)"; String actual = DbInterpretter.Execute("use -h"); Assert.AreEqual(expected, actual); }
public void CorrectUseOfUse() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); }
public void UseWithoutParams() { String expected = "Invalid DBname"; String actual = DbInterpretter.Execute("use"); Assert.AreEqual(expected, actual); }
public void ExecuteUpdateHelp() { String expected = "Update <table name> set <field=value>+ where <condition> |-> Update table entries on selected fields"; String actual = DbInterpretter.Execute("update -h"); Assert.AreEqual(expected, actual); }
public void ExecuteHelpHelp() { String expected = "help |-> this help"; String actual = DbInterpretter.Execute("help -h"); Assert.AreEqual(expected, actual); }
public void ExecuteByeHelp() { String expected = "bye |-> quit"; String actual = DbInterpretter.Execute("bye -h"); Assert.AreEqual(expected, actual); }
public void SelectWithWhereTest3() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Ok"; actual = DbInterpretter.Execute("create tab (col1, col2)"); Assert.AreEqual(expected, actual); expected = "result:\ncol1 col2"; actual = DbInterpretter.Execute("Select * from tab"); Assert.AreEqual(expected, actual); expected = "Ok"; actual = DbInterpretter.Execute("Insert into tab (col1, col2) values (content1, content2)"); Assert.AreEqual(expected, actual); expected = "result:\n col1 col2\ncontent1 content2"; actual = DbInterpretter.Execute("Select * from tab where col1!='c'"); //Assert.AreEqual(expected, actual); expected = "result:\n col1 col2\ncontent1 content2"; actual = DbInterpretter.Execute("Select * from tab where col1=='content1'"); //Assert.AreEqual(expected, actual); expected = "result:\n col1 col2\ncontent1 content2"; actual = DbInterpretter.Execute("Select * from tab where col1 startswith 'c'"); // Assert.AreEqual(expected, actual); expected = "result:\n col1 col2\ncontent1 content2"; actual = DbInterpretter.Execute("Select * from tab where col1 endswith '1'"); //Assert.AreEqual(expected, actual); }
public void ExecuteInsertHelp() { String expected = "Insert into <table name> (<fields list>) values (<values list>) |-> Insert int table on current db"; String actual = DbInterpretter.Execute("insert -h"); Assert.AreEqual(expected, actual); }
public void ExecuteSelectHelp() { String expected = "Select <*|fields list> from <table> [where <condition>] |-> List tables from current db"; String actual = DbInterpretter.Execute("select -h"); Assert.AreEqual(expected, actual); }
public void ExecuteDeleteHelp() { String expected = "Delete from <table name> where <condition> |-> Delete table from current db"; String actual = DbInterpretter.Execute("delete -h"); Assert.AreEqual(expected, actual); }
public void SaveCommandTest() { DbInterpretter.Execute("use unitTestingDB"); DbInterpretter.Execute("create tab (col1, col2)"); DbInterpretter.Execute("Insert into tab (col1, col2) values (content1, content2)"); //Assert.AreEqual(DbInterpretter.Execute("save d:\\"), "Database unitTestingDB saved."); Assert.AreEqual(DbInterpretter.Execute("save tab d:\\"), "Table tab saved."); }
public void ExecuteSaveHelp() { String expected = "Save [path] |-> Saves the database to a provided or default path " + "\nSave tableName [path] [CSV] |-> Saves a table from current DB to a provided or default path"; String actual = DbInterpretter.Execute("Save -h"); Assert.AreEqual(expected, actual); }
public void ByeTest() { String expected = "Bye!"; String actual = DbInterpretter.Execute("bye"); Assert.AreEqual(actual, expected); Assert.AreEqual(DbInterpretter.isRunning, false); }
public void ExecuteRestoreHelp() { String expected = "Restore [path [CSV]] |-> Restore the database from a provided or default path " + "\nRestore tbName [path [CSV]] |-> Restore a table from current DB from a provided or default path"; String actual = DbInterpretter.Execute("Restore -h"); Assert.AreEqual(expected, actual); }
public void InsertWithoutParamsTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database error: No table named "; actual = DbInterpretter.Execute("insert"); Assert.AreEqual(expected, actual); }
public void SelectWithoutTableTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database error: No table named unitTestingDB"; actual = DbInterpretter.Execute("select * from unitTestingDB"); Assert.AreEqual(expected, actual); }
public void RestoreWithoutParamsTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database error: Invalid db load path path:DB.unitTestingDB"; actual = DbInterpretter.Execute("restore"); Assert.AreEqual(expected, actual); }
public void CreateWithoutColumns() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Console error: Syntax error"; actual = DbInterpretter.Execute("Create unitTestingTable1"); Assert.AreEqual(expected, actual); }
public void DropWithoutParamsTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database error: Table not in db."; actual = DbInterpretter.Execute("drop"); Assert.AreEqual(expected, actual); }
public void SaveCurrentDatabaseTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database unitTestingDB saved."; actual = DbInterpretter.Execute("save"); Assert.AreEqual(expected, actual); }
public void SaveCSVFormatTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Database unitTestingDB saved."; actual = DbInterpretter.Execute("save D:\\Facultate_Master\\ISS\\sem2\\CSS\\Project\\CSS-database\\database\\bin\\Debug\\csv CSV"); Assert.AreEqual(expected, actual); }
public void CreateWithColumns() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Ok"; actual = DbInterpretter.Execute("Create unitTestingTable1 (col1, col2)"); Assert.AreEqual(expected, actual); }
public void CreateWithoutParamsTest() { String expected = "Database unitTestingDB set active as empty. you can try to restore."; String actual = DbInterpretter.Execute("use unitTestingDB"); Assert.AreEqual(expected, actual); expected = "Ok"; actual = DbInterpretter.Execute("create"); Assert.AreEqual(expected, actual); }
public void UpdateWithParamsTest() { DbInterpretter.Execute("use unitTestingDB"); DbInterpretter.Execute("create tab (col1, col2)"); DbInterpretter.Execute("Insert into tab (col1, col2) values (content1, content2)"); String expected = "Ok"; String actual = DbInterpretter.Execute("update tab set col2='new' where col1=='content1'"); Assert.AreEqual(expected, actual); }
public void RestoreTest() { String expected = "Database error: No table named unitTestingDB"; String actual = DbInterpretter.Execute("restore unitTestingDB"); Assert.AreEqual(expected, actual); DbInterpretter.Execute("use unitTestingDB"); actual = DbInterpretter.Execute("restore"); Assert.AreEqual("Database unitTestingDB restored.", actual); }
public void SaveDefaultFormatTest() { DbInterpretter.Execute("use unitTestingDB"); DbInterpretter.Execute("create tab (col1, col2)"); DbInterpretter.Execute("Insert into tab (col1, col2) values (content1, content2)"); string expected = "Database unitTestingDB saved."; string actual = DbInterpretter.Execute("save"); Assert.AreEqual(expected, actual); }
private void Execute_Click(object sender, EventArgs e) { CommandOutput.AppendText("\n>>>" + CommandInput.Text + "\n"); CommandOutput.AppendText(DbInterpretter.Execute(CommandInput.Text) + '\n'); CommandInput.Clear(); if (!DbInterpretter.isRunning) { Close(); } UpdateDbInfo(); }
public static void Run(string[] init) { Trace.Assert(init != null, "init == null"); Console.Out.WriteLine("Known databases:\n" + String.Join("\n", Database.GetKnownDBs())); foreach (string comm in init) { Console.Out.WriteLine(DbInterpretter.Execute(comm)); } while (DbInterpretter.isRunning) { Console.Out.Write(DbInterpretter.currentDb.name + ">"); Console.Out.WriteLine(DbInterpretter.Execute(Console.In.ReadLine())); } }