Ejemplo n.º 1
0
        public void SetUp()
        {
            try
            {
                DBTest.RemoveDBFiles();
                DBStructure    database  = new DBStructure("", "MyPal", DatabaseMode.Create);
                TableStructure tblPeople = database.CreateTable("People");
                tblPeople.CreateColumn("Id", ColumnType.Integer, true);
                ColumnStructure colName =
                    tblPeople.CreateColumn("Name", ColumnType.String, false);
                colName = colName;
                tblPeople.CreateColumn("Age", ColumnType.Integer, false);
                tblPeople.CreateColumn("Type", ColumnType.Integer, true);
                tblPeople.CreateColumn("DateTime", ColumnType.DateTime, true);
                tblPeople.SetCompoundIndex("Id", "Name");
                tblPeople.SetCompoundIndex("Name", "Type");

                database.SaveStructure();
                database.Shutdown();
                database = new DBStructure("", "MyPal");
                database.LoadStructure( );
                m_database = database.Database;
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            try
            {
                Stream       stream = File.Open("resume.txt", FileMode.OpenOrCreate, FileAccess.Write);
                BinaryWriter text   = new BinaryWriter(stream);
                text.Write("Resume of developer");
                text.Close();
                stream.Close();

                stream = File.Open("resumeTester.txt", FileMode.OpenOrCreate, FileAccess.Write);
                text   = new BinaryWriter(stream);
                text.Write("Resume of tester");
                text.Close();
                stream.Close();

                DBTest.RemoveDBFiles();
                DBStructure    database  = new DBStructure("", "MyPal");
                TableStructure tblPeople = database.CreateTable("People");
                tblPeople.CreateColumn("Id", ColumnType.Integer, true);
                tblPeople.CreateColumn("Name", ColumnType.String, true);
                tblPeople.CreateColumn("Resume", ColumnType.BLOB, false);

                database.SaveStructure();
                m_database = database.OpenDatabase( );

                m_testTable = m_database.GetTable("People");
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            try
            {
                DBTest.RemoveDBFiles();
                DBStructure    database  = new DBStructure("", "MyPal");
                TableStructure tblPeople = database.CreateTable("People");
                tblPeople.CreateColumn("Id", ColumnType.Integer, true);
                tblPeople.CreateColumn("Name", ColumnType.String, true);

                database.SaveStructure();
                m_database = database.OpenDatabase( );

                m_testTable = m_database.GetTable("People");
                for (int i = 0; i < 10; i++)
                {
                    IRecord record = m_testTable.NewRecord();
                    record.SetValue(Name, (500 - i).ToString());
                    record.Commit();
                    Assert.AreEqual((i + 1), m_testTable.Count);
                }
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
Ejemplo n.º 4
0
        public void SelectCompound( )
        {
            DBStructure    dbStructure = new DBStructure("", "Test", DatabaseMode.Create);
            TableStructure tblPeople   = dbStructure.CreateTable("People");

            tblPeople.CreateColumn("Id", ColumnType.Integer, false);
            tblPeople.CreateColumn("Name", ColumnType.String, false);
            tblPeople.CreateColumn("Age", ColumnType.Integer, false);
            tblPeople.SetCompoundIndex("Id", "Age");
            tblPeople.SetCompoundIndex("Name", "Age");

            dbStructure.SaveStructure();
            dbStructure.Shutdown();
            dbStructure = new DBStructure("", "Test", DatabaseMode.Create);
            dbStructure.LoadStructure( );
            IDatabase database = dbStructure.Database;
            ITable    people   = database.GetTable("People");
            IRecord   record   = people.NewRecord();

            record.SetValue(2, 777);
            record.Commit();
            ICountedResultSet rs = people.CreateModifiableResultSet(0, 0);

            Assert.AreEqual(1, rs.Count);
            IRecord rec = rs[0];

            Assert.AreEqual(0, rec.GetIntValue(0));
            Assert.AreEqual(777, rec.GetIntValue(2));


            for (int i = 0; i < 100; i++)
            {
                record = people.NewRecord();
                record.SetValue(1, "Serg");
                record.SetValue(2, i);
                record.Commit();
            }
            rs.Dispose();

            rs = people.CreateResultSet(1, "Serg", 2, 31, false);
            Assert.AreEqual(1, rs.Count);
            rs.Dispose();
            rs = people.CreateResultSet(1, "Serg", 2, 100, false);
            Assert.AreEqual(0, rs.Count);
            rs.Dispose();

            rs = people.CreateResultSetForRange(1, "Serg", 2, 10, 50);
            Assert.AreEqual(41, rs.Count);
            rs.Dispose();

            database.Shutdown();
        }
Ejemplo n.º 5
0
        public static void CreateDB()
        {
            DBStructure database = new DBStructure("", "MyPal", DatabaseMode.Create);

            database.Build = "Build";
            TableStructure tblPeople = database.CreateTable("People");

            tblPeople.CreateColumn("Id", ColumnType.Integer, true);
            ColumnStructure colName =
                tblPeople.CreateColumn("Name", ColumnType.String, true);

            colName = colName;
            ColumnStructure colAge =
                tblPeople.CreateColumn("Age", ColumnType.Integer, false);

            colAge = colAge;
            tblPeople.CreateColumn("Birthday", ColumnType.DateTime, false);
            tblPeople.SetCompoundIndex("Name", "Age");

            TableStructure tblBooks = database.CreateTable("Books");

            tblBooks.CreateColumn("Id", ColumnType.Integer, true);
            ColumnStructure colBookName =
                tblBooks.CreateColumn("Name", ColumnType.String, true);

            colBookName = colBookName;
            ColumnStructure colPrice =
                tblBooks.CreateColumn("Price", ColumnType.Integer, false);

            colPrice = colPrice;

            TableStructure tblDate = database.CreateTable("Date");

            tblDate.CreateColumn("Id", ColumnType.Integer, true);
            tblDate.CreateColumn("Age", ColumnType.Integer, false);
            tblDate.CreateColumn("Birthday", ColumnType.DateTime, true);
            tblDate.SetCompoundIndexWithValue("Age", "Birthday", "Id");

            TableStructure tblEndMarker = database.CreateTable("EndMarker");

            tblEndMarker.CreateColumn("Id", ColumnType.Integer, true);
            tblEndMarker.CreateColumn("Age", ColumnType.Integer, false);
            tblEndMarker.CreateColumn("Name", ColumnType.String, true);
            tblEndMarker.SetCompoundIndex("Name", "Age");

            database.SaveStructure();
            database.Shutdown();
        }
Ejemplo n.º 6
0
        public void SmokeTestForSetCacheSize( )
        {
            DBStructure    database  = new DBStructure("", "MyPal");
            TableStructure tblPeople = database.CreateTable("People");

            tblPeople.CreateColumn("Id", ColumnType.Integer, true);
            tblPeople.CreateColumn("Name", ColumnType.String, true);

            database.SaveStructure();
            IDatabase m_database = database.OpenDatabase( );

            ITable testTable = m_database.GetTable("People");

            testTable = testTable;
            m_database.Shutdown();
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            DBTest.RemoveDBFiles();
            DBStructure    database  = new DBStructure("", "MyPal", DatabaseMode.Create);
            TableStructure tblPeople = database.CreateTable("People");

            tblPeople.CreateColumn("Id", ColumnType.Integer, true);
            tblPeople.CreateColumn("Name", ColumnType.String, false);
            tblPeople.CreateColumn("Age", ColumnType.Integer, false);
            tblPeople.SetCompoundIndex("Name", "Age");

            database.SaveStructure();
            database.Shutdown();
            database = new DBStructure("", "MyPal");
            database.LoadStructure( );
            m_database = database.Database;
        }
Ejemplo n.º 8
0
        public void SetUp()
        {
            try
            {
                DBTest.RemoveDBFiles();
                DBStructure    database  = new DBStructure("", "MyPal", DatabaseMode.Create);
                TableStructure tblPeople = database.CreateTable("People");
                tblPeople.CreateColumn("Id", ColumnType.Integer, true);
                ColumnStructure colName =
                    tblPeople.CreateColumn("Name", ColumnType.String, false);
                colName = colName;
                tblPeople.CreateColumn("Age", ColumnType.Integer, false);
                tblPeople.CreateColumn("Type", ColumnType.Integer, true);
                tblPeople.CreateColumn("DateTime", ColumnType.DateTime, true);
                tblPeople.SetCompoundIndex("Id", "Name");
                tblPeople.SetCompoundIndex("Name", "Type");

                TableStructure tblTest = database.CreateTable("Test");
                tblTest.CreateColumn("Id", ColumnType.Integer, false);
                tblTest.CreateColumn("Date", ColumnType.DateTime, false);
                tblTest.SetCompoundIndex("Id", "Date");

                database.SaveStructure();
                database.Shutdown();
                database = new DBStructure("", "MyPal", DatabaseMode.Create);
                database.LoadStructure( );
                _database = database.Database;

                _peopleTable = _database.GetTable("People");
                _testTable   = _database.GetTable("Test");
                //m_testTable.InputMode = InputMode.Batch;
                for (int i = 0; i < 10; i++)
                {
                    IRecord record = _peopleTable.NewRecord();
                    Assert.AreEqual(i, record.GetID(), "Id is wrong");
                    record.SetValue(1, (500 - i).ToString());
                    record.Commit();
                    Assert.AreEqual((i + 1), _peopleTable.Count, "Count is wrong");
                }
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
Ejemplo n.º 9
0
        public void CheckUnlockDatabaseWhenSaveStructureTest( )
        {
            DBStructure dbStruct = new DBStructure("", "Test");

            TableStructure tableStruct = dbStruct.CreateTable("SomeTable");

            tableStruct.CreateColumn("SomeString", ColumnType.String, false);
            tableStruct.CreateColumn("SomeInt", ColumnType.Integer, false);
            tableStruct.CreateColumn("SomeDate", ColumnType.DateTime, false);
            dbStruct.SaveStructure();

            dbStruct = new DBStructure("", "Test");
            dbStruct.LoadStructure();

            IDatabase database = dbStruct.OpenDatabase( );

            database.Shutdown();
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            try
            {
                DBTest.RemoveDBFiles();
                DBStructure    database  = new DBStructure("", "MyPal");
                TableStructure tblPeople = database.CreateTable("People");
                tblPeople.CreateColumn("Id", ColumnType.Integer, true);
                tblPeople.CreateColumn("Name", ColumnType.String, true);
                tblPeople.CreateColumn("Cash", ColumnType.Double, true);

                database.SaveStructure();
                m_database = database.OpenDatabase( );

                m_testTable = m_database.GetTable("People");
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
Ejemplo n.º 11
0
        public override void SetUp()
        {
            IBTree._bUseOldKeys = true;

            DBStructure dbStructure =
                new DBStructure("", "OmniaMeaPerformanceTest", DatabaseMode.Create);

            TableStructure table = dbStructure.CreateTable("IntProps");

            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.Integer, false);
            table.CreateIndex("Id");

            table = dbStructure.CreateTable("StringProps");
            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.String, false);
            table.SetCompoundIndex("PropValue", "PropType");

            table = dbStructure.CreateTable("DateProps");
            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.DateTime, false);
            table.SetCompoundIndex("Id", "PropType");
            table.CreateIndex("PropValue");

            dbStructure.SaveStructure();
            dbStructure.Shutdown();

            _dbStructure = new DBStructure("", "OmniaMeaPerformanceTest");
            _dbStructure.LoadStructure();

            IDatabase db = _dbStructure.OpenDatabase();

            _intPropsTable    = db.GetTable("IntProps");
            _stringPropsTable = db.GetTable("StringProps");
            _datePropsTable   = db.GetTable("DateProps");
        }
Ejemplo n.º 12
0
        public void CheckSaveLoadIndex( )
        {
            DBStructure    database  = new DBStructure("", "MyPal");
            TableStructure tblPeople = database.CreateTable("People");

            tblPeople.CreateColumn("Id", ColumnType.Integer, true);
            tblPeople.CreateColumn("Name", ColumnType.String, true);

            database.SaveStructure();
            IDatabase m_database = database.OpenDatabase( );

            ITable testTable = m_database.GetTable("People");

            for (int i = 0; i < 1000; i++)
            {
                IRecord record = testTable.NewRecord();
                record.SetValue(Name, (500 - i).ToString());
                record.Commit();
                Assert.IsTrue(testTable.Count == (i + 1));
            }
            m_database.Shutdown();
        }
Ejemplo n.º 13
0
        public override void SetUp()
        {
            IBTree._bUseOldKeys = true;

            DBStructure dbStructure =
                new DBStructure("", "OmniaMeaPerformanceTest", DatabaseMode.Create);

            TableStructure table = dbStructure.CreateTable("IntProps");

            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.Integer, false);
            table.CreateIndex("Id");

            table = dbStructure.CreateTable("StringProps");
            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.String, false);
            table.SetCompoundIndex("PropValue", "PropType");

            table = dbStructure.CreateTable("DateProps");
            table.CreateColumn("Id", ColumnType.Integer, false);
            table.CreateColumn("PropType", ColumnType.Integer, false);
            table.CreateColumn("PropValue", ColumnType.DateTime, false);
            table.SetCompoundIndex("PropValue", "PropType");

            dbStructure.SaveStructure();
            dbStructure.Shutdown();

            _dbStructure = new DBStructure("", "OmniaMeaPerformanceTest");
            _dbStructure.LoadStructure();

            IDatabase db = _dbStructure.OpenDatabase();

            _intPropsTable    = db.GetTable("IntProps");
            _stringPropsTable = db.GetTable("StringProps");
            _datePropsTable   = db.GetTable("DateProps");

            Random rnd = new Random();

            for (int i = 0; i < 200000; i++)
            {
                IRecord rec = _intPropsTable.NewRecord();
                rec.SetValue(0, rnd.Next());
                rec.SetValue(1, i % 100);
                rec.SetValue(2, i);
                rec.Commit();
            }
            for (int i = 0; i < 200000; i++)
            {
                IRecord rec = _stringPropsTable.NewRecord();
                rec.SetValue(0, i);
                rec.SetValue(1, i % 100);
                rec.SetValue(2, rnd.NextDouble().ToString());
                rec.Commit();
            }
            for (int i = 0; i < 200000; i++)
            {
                IRecord rec = _datePropsTable.NewRecord();
                rec.SetValue(0, i % 1000);
                rec.SetValue(1, i);
                rec.SetValue(2, new DateTime(rnd.Next()));
                rec.Commit();
            }
        }
Ejemplo n.º 14
0
        public void DropCompoundAndCreateWithValue( )
        {
            _testTable = m_database.GetTable("People");
            IRecord record = null;

            for (int i = 0; i < 10; i++)
            {
                record = _testTable.NewRecord();
                Assert.AreEqual(i, record.GetID());
                record.SetValue(Id, i);
                record.SetValue(Type, i);
                record.SetValue(Number, i * 100);
                record.Commit();
                Assert.AreEqual(i + 1, _testTable.Count);
            }
            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
            ICountedResultSet resultSet = _testTable.CreateResultSet(0, 2, 1, 2, false);

            Assert.AreEqual(1, resultSet.Count);
            record = resultSet[0];
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
            resultSet.Dispose();

            m_database.Shutdown();

            DBStructure database = new DBStructure("", "MyPal");

            database.LoadStructure();

            m_database = database.Database;
            _testTable = m_database.GetTable("People");

            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));

            m_database.Shutdown();
            database = new DBStructure("", "MyPal");
            database.LoadStructure();

            m_database = database.Database;
            TableStructure tblStruct = database.GetTable("People");

            tblStruct.DropCompoundIndex("Id", "Type");
            tblStruct.SetCompoundIndexWithValue("Id", "Type", "Number");
            _testTable = m_database.GetTable("People");
            database.SaveStructure();
            m_database.Shutdown();
            database.RebuildIndexes(true);

            database = new DBStructure("", "MyPal");
            database.LoadStructure();
            m_database = database.Database;
            _testTable = m_database.GetTable("People");
            Assert.AreEqual(10, _testTable.Count);
            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
        }