Esempio n. 1
0
        public void ExecuteDropHelp()
        {
            String expected = "Drop tbName                   |-> Drop table from current db";
            String actual   = DbInterpretter.Execute("drop -h");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void ExecuteUseHelp()
        {
            String expected = "Use DBname                    |-> Set the DBname database active (as empty)";
            String actual   = DbInterpretter.Execute("use -h");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public void UseWithoutParams()
        {
            String expected = "Invalid DBname";
            String actual   = DbInterpretter.Execute("use");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public void ExecuteHelpHelp()
        {
            String expected = "help                          |-> this help";
            String actual   = DbInterpretter.Execute("help -h");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 8
0
        public void ExecuteByeHelp()
        {
            String expected = "bye                           |-> quit";
            String actual   = DbInterpretter.Execute("bye -h");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 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.");
 }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        public void ByeTest()
        {
            String expected = "Bye!";
            String actual   = DbInterpretter.Execute("bye");

            Assert.AreEqual(actual, expected);
            Assert.AreEqual(DbInterpretter.isRunning, false);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
 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();
 }
Esempio n. 30
0
 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()));
     }
 }