コード例 #1
0
ファイル: DatabaseTests.cs プロジェクト: olexdav/DBMS-lab
        public void JoinTablesTest()
        {
            // Create tables
            DBTable leftTable = new DBTable();

            leftTable.AddField("Name", "String");
            leftTable.AddField("ValX", "Integer");
            DBTable rightTable = new DBTable();

            rightTable.AddField("Name", "String");
            rightTable.AddField("ValY", "Integer");
            DBTable joinedTable = new DBTable();

            joinedTable.AddField("Name", "String");
            joinedTable.AddField("ValX", "Integer");
            joinedTable.AddField("ValY", "Integer");
            // Fill tables
            DBRow row = new DBRow();

            row.AddElement(new EString("A"));
            row.AddElement(new EInteger(1));
            leftTable.AddRow(row);
            row = new DBRow();
            row.AddElement(new EString("B"));
            row.AddElement(new EInteger(2));
            leftTable.AddRow(row);
            row = new DBRow();
            row.AddElement(new EString("B"));
            row.AddElement(new EInteger(3));
            rightTable.AddRow(row);
            row = new DBRow();
            row.AddElement(new EString("C"));
            row.AddElement(new EInteger(4));
            rightTable.AddRow(row);
            row = new DBRow();
            row.AddElement(new EString("B"));
            row.AddElement(new EInteger(2));
            row.AddElement(new EInteger(3));
            joinedTable.AddRow(row);
            Database db = new Database();

            db.JoinTables(leftTable, 0, rightTable, 0);
            Assert.AreEqual(joinedTable, db.GetTable(0));
        }
コード例 #2
0
        public void CompareTablesTest()
        {
            DBTable lTable = new DBTable();
            DBTable rTable = new DBTable();

            lTable.AddField("field", "String");
            rTable.AddField("field", "String");
            EString el  = new EString("Sample");
            DBRow   row = new DBRow();

            row.AddElement(el);
            lTable.AddRow(row);
            el  = new EString("Sample");
            row = new DBRow();
            row.AddElement(el);
            rTable.AddRow(row);
            Assert.AreEqual(lTable, rTable);
        }
コード例 #3
0
        public void SearchTest()
        {
            DBTable searchTable = new DBTable();
            DBTable resultTable = new DBTable();

            searchTable.AddField("field", "String");
            resultTable.AddField("field", "String");
            DBRow   row = new DBRow();
            EString el  = new EString("RISC");

            row.AddElement(el);
            searchTable.AddRow(row);
            resultTable.AddRow(row);
            row = new DBRow();
            el  = new EString("CISC");
            row.AddElement(el);
            searchTable.AddRow(row);
            Assert.AreEqual(resultTable, searchTable.Search("R", "String"));
        }