private void Cursor10000Test() { //create database Hamster.Environment env = new Hamster.Environment(); env.Create("ntest.db"); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = HamConst.HAM_PARAM_KEY_TYPE; param[0].value = HamConst.HAM_TYPE_UINT64; Database db = env.CreateDatabase(1, 0, param); //insert records for (ulong i = 0; i < 10000; i++) { byte[] key = BitConverter.GetBytes(i); byte[] record = new byte[20]; db.Insert(key, record); } //close database db.Close(); //reopen again db = env.OpenDatabase(1); Cursor cursor = new Cursor(db); cursor.MoveFirst(); ulong firstKey = BitConverter.ToUInt64(cursor.GetKey(), 0); Assert.AreEqual((ulong)0, firstKey); cursor.MoveLast(); ulong lastKey = BitConverter.ToUInt64(cursor.GetKey(), 0); Assert.AreEqual((ulong)9999, lastKey); //close database cursor.Close(); db.Close(); env.Close(); }
public void MoveLast() { Cursor c = new Cursor(db); byte[] k = new byte[5]; byte[] r = new byte[5]; db.Insert(k, r); c.MoveLast(); }
public void Cursor10000Test() { //create database Database hamster = CreateDatabase("test.db"); //insert records for (ulong i = 0; i < 10000; i++) { byte[] key = BitConverter.GetBytes(i); byte[] record = new byte[20]; hamster.Insert(key, record); } //close database hamster.Close(); //reopen again hamster = OpenDatabase("test.db"); Cursor cursor = new Cursor(hamster); cursor.MoveFirst(); ulong firstKey = BitConverter.ToUInt64(cursor.GetKey(), 0); Assert.AreEqual((ulong)0, firstKey); cursor.MoveLast(); ulong lastKey = BitConverter.ToUInt64(cursor.GetKey(), 0); Assert.AreEqual((ulong)9999, lastKey); //close database cursor.Close(); hamster.Close(); }