private void Flush() { Upscaledb.Environment env = new Upscaledb.Environment(); env.Create("ntest.db"); env.Flush(); env.Close(); }
private void InsertKeyInvalidParam() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r = new byte[5]; env.Create("ntest.db"); db = env.CreateDatabase(1); try { db.Insert(null, r); } catch (NullReferenceException) { } try { db.Insert(k, null); } catch (NullReferenceException) { } try { db.Insert(k, r, 9999); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); } db.Close(); env.Close(); }
private void SetUp() { env = new Upscaledb.Environment(); db = new Database(); env.Create("ntest.db"); db = env.CreateDatabase(1, UpsConst.UPS_ENABLE_DUPLICATE_KEYS); }
private void InsertRecNo() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] r1 = new byte[5]; byte[] r2; try { env.Create("ntest.db"); db = env.CreateDatabase(1, UpsConst.UPS_RECORD_NUMBER); r1[0] = 1; var k = db.InsertRecNo(r1); r2 = db.Find(k); checkEqual(r1, r2); r1[0] = 2; k = db.InsertRecNo(r1); r2 = db.Find(k); checkEqual(r1, r2); r1[0] = 3; k = db.InsertRecNo(r1); r2 = db.Find(k); checkEqual(r1, r2); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } db.Close(); env.Close(); }
private void InsertKey() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r1 = new byte[5]; byte[] r2; try { env.Create("ntest.db"); db = env.CreateDatabase(1); k[0] = 1; r1[0] = 1; db.Insert(k, r1); r2 = db.Find(k); checkEqual(r1, r2); k[0] = 2; r1[0] = 2; db.Insert(k, r1); r2 = db.Find(k); checkEqual(r1, r2); k[0] = 3; r1[0] = 3; db.Insert(k, r1); r2 = db.Find(k); checkEqual(r1, r2); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
private void SetComparator() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r = new byte[5]; Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_KEY_TYPE; param[0].value = UpsConst.UPS_TYPE_CUSTOM; compareCounter = 0; try { env.Create("ntest.db"); db = env.CreateDatabase(1, 0, param); db.SetCompareFunc(new CompareFunc(MyCompareFunc)); db.Insert(k, r); k[0] = 1; db.Insert(k, r); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } Assert.AreEqual(1, compareCounter); }
private void CreateWithParameters2() { using (Upscaledb.Environment env = new Upscaledb.Environment()) { env.Create("ntest.db"); using (Database db = env.CreateDatabase(13, 0, new Parameter[0])) { } } }
private void CreateStringNull() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create(null); env.Close(); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); } }
private void CreateStringInt() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create(null, UpsConst.UPS_IN_MEMORY); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
private void CreateStringIntInt() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create("ntest.db", 0, 0644); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
private void CreateDatabaseNegative() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create("ntest.db"); Database db = env.CreateDatabase((short)0); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); } env.Close(); }
private void OpenDatabaseNegative() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create("ntest.db"); Database db = env.OpenDatabase((short)99); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_DATABASE_NOT_FOUND, e.ErrorCode); } env.Close(); }
private void AutoCleanupCursors() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create("ntest.db"); db = env.CreateDatabase(1); Cursor cursor = new Cursor(db); // let gc do the cleanup env.Close(); }
private void CreateWithParameters() { using (Upscaledb.Environment env = new Upscaledb.Environment()) { env.Create("ntest.db"); Parameter[] param = new Parameter[] { new Parameter { name = UpsConst.UPS_PARAM_KEYSIZE, value = 32 } }; using (Database db = env.CreateDatabase(13, 0, param)) { } } }
private void Recovery() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create("ntest.db", UpsConst.UPS_ENABLE_RECOVERY); db = env.CreateDatabase(1); byte[] k = new byte[5]; byte[] r = new byte[5]; db.Insert(k, r); db.Close(); env.Close(); }
private void Transactions() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create("ntest.db", UpsConst.UPS_ENABLE_TRANSACTIONS); db = env.CreateDatabase(1); byte[] k = new byte[5]; byte[] r = new byte[5]; db.Insert(k, r); db.Close(); env.Close(); }
private void FindKeyNull() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); try { env.Create("ntest.db"); db = env.CreateDatabase(1); byte[] r = db.Find(null); } catch (NullReferenceException) { } db.Close(); env.Close(); }
private void CreateStringIntIntParameter() { Upscaledb.Environment env = new Upscaledb.Environment(); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_CACHE_SIZE; param[0].value = 1000; try { env.Create("ntest.db", 0, 0644, param); env.Close(); } catch (DatabaseException e) { Assert.Fail("Unexpected exception " + e); } }
private void SetErrorHandler() { Upscaledb.Environment env = new Upscaledb.Environment(); ErrorHandler eh = new ErrorHandler(MyErrorHandler); try { Database.SetErrorHandler(eh); env.Create(null); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); Assert.AreEqual(1, errorCounter); } Database.SetErrorHandler(null); }
private void CreateStringIntIntParameterNeg() { Upscaledb.Environment env = new Upscaledb.Environment(); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_PAGESIZE; param[0].value = 777; try { env.Create("ntest.db", 0, 0644, param); env.Close(); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PAGESIZE, e.ErrorCode); } }
private void EraseKeyNegative() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; env.Create("ntest.db"); db = env.CreateDatabase(1); try { db.Erase(null); } catch (NullReferenceException) { } db.Close(); env.Close(); }
private void EraseUnknownKey() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; env.Create("ntest.db"); db = env.CreateDatabase(1); try { db.Erase(k); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_KEY_NOT_FOUND, e.ErrorCode); } db.Close(); env.Close(); }
private void CreateInvalidParameter() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); Parameter[] param = new Parameter[3]; param[1] = new Parameter(); param[2] = new Parameter(); try { env.Create("ntest.db"); db = env.CreateDatabase(1, 0, param); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); } }
private void EraseUnknownDatabase() { Upscaledb.Environment env = new Upscaledb.Environment(); byte[] k = new byte[5]; byte[] r = new byte[5]; env.Create("ntest.db"); Database db = env.CreateDatabase((short)13); db.Insert(k, r); db.Close(); try { env.EraseDatabase((short)99); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_DATABASE_NOT_FOUND, e.ErrorCode); } env.Close(); }
private void CreateString() { Database db = new Database(); Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create("ntest.db"); db = env.CreateDatabase(1); db.Close(); env.Close(); env.Open("ntest.db"); db = env.OpenDatabase(1); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("Unexpected exception " + e); } }
private void GetKeyCount() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create("ntest.db"); db = env.CreateDatabase(1); byte[] k = new byte[5]; byte[] r = new byte[5]; Assert.AreEqual(0, db.GetCount()); db.Insert(k, r); Assert.AreEqual(1, db.GetCount()); k[0] = 1; db.Insert(k, r); Assert.AreEqual(2, db.GetCount()); db.Close(); env.Close(); }
private void InsertKeyNegative() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r = new byte[5]; try { env.Create("ntest.db"); db = env.CreateDatabase(1); db.Insert(k, r); db.Insert(k, r); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_DUPLICATE_KEY, e.ErrorCode); } db.Close(); env.Close(); }
private void Cursor10000Test() { //create database Upscaledb.Environment env = new Upscaledb.Environment(); env.Create("ntest.db"); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_KEY_TYPE; param[0].value = UpsConst.UPS_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(); }
private void CreateDatabaseShort() { Upscaledb.Environment env = new Upscaledb.Environment(); byte[] k = new byte[5]; byte[] r = new byte[5]; try { env.Create("ntest.db"); Database db = env.CreateDatabase((short)13); db.Insert(k, r); db.Close(); db = env.OpenDatabase((short)13); byte[] f = db.Find(k); checkEqual(r, f); // db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
public void Start(string context, int recordCount, int?threadCount = null) { Log.Clear(); Context = context; RecordCount = recordCount; ThreadCount = threadCount; var engine = GetType().Name; Log.AppendLine($"# Context: {Context} | Engine: {engine} | Records: {recordCount} | Threads: {threadCount}"); var databaseName = $@"{context.Replace(" ", "_").ToLower()}_{engine.ToLower()}.db"; if (Directory.Exists(databaseName)) { Directory.Delete(databaseName, true); } var databasePath = Path.Combine(System.Environment.CurrentDirectory, databaseName); var environment = new Upscaledb.Environment(); var db = new Database(); environment.Create(databaseName); db = environment.CreateDatabase(1); var stopWatch = new Stopwatch(); stopWatch.Start(); _actions.ForEach(action => action(db)); stopWatch.Stop(); environment.Flush(); environment.Close(); db.Close(); Log.AppendFormat("# Context: {0} | Engine: {1} | Total time: {2:hh\\:mm\\:ss\\.ffff}\n", Context, engine, stopWatch.Elapsed); Log.AppendLine("\n"); }
private Database CreateDatabase(string file) { List<Parameter> list = new List<Parameter>(); Parameter param1 = new Parameter(); param1.name = UpsConst.UPS_PARAM_CACHESIZE; param1.value = 768 * 1024 * 1024; list.Add(param1); Parameter param2 = new Parameter(); param2.name = UpsConst.UPS_PARAM_KEYSIZE; param2.value = 8; // sizeof(ulong); list.Add(param2); Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create(file, 0, 0, list.ToArray()); db = env.CreateDatabase(1); db.SetCompareFunc(new CompareFunc(NumericalCompareFunc)); return db; }
private void FindUnknownKey() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; try { env.Create("ntest.db"); db = env.CreateDatabase(1); byte[] r = db.Find(k); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_KEY_NOT_FOUND, e.ErrorCode); } db.Close(); env.Close(); }
private void RenameDatabase() { Upscaledb.Environment env = new Upscaledb.Environment(); byte[] k = new byte[5]; byte[] r = new byte[5]; try { env.Create("ntest.db"); Database db = env.CreateDatabase((short)13); db.Insert(k, r); db.Close(); env.RenameDatabase((short)13, (short)15); db = env.OpenDatabase((short)15); byte[] f = db.Find(k); checkEqual(r, f); // db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
private void ApproxMatching() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k1 = new byte[5]; byte[] r1 = new byte[5]; k1[0] = 1; r1[0] = 1; byte[] k2 = new byte[5]; byte[] r2 = new byte[5]; k2[0] = 2; r2[0] = 2; byte[] k3 = new byte[5]; byte[] r3 = new byte[5]; k3[0] = 3; r3[0] = 3; try { env.Create("ntest.db"); db = env.CreateDatabase(1); db.Insert(k1, r1); db.Insert(k2, r2); db.Insert(k3, r3); Cursor c = new Cursor(db); byte[] r = c.Find(k2, UpsConst.UPS_FIND_GT_MATCH); checkEqual(r, r3); checkEqual(k2, k3); k2[0] = 2; r = c.Find(k2, UpsConst.UPS_FIND_GT_MATCH); checkEqual(r, r1); checkEqual(k2, k1); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
private void CreateStringIntIntParameterNeg() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_CACHESIZE; param[0].value = 1024; try { env.Create("ntest.db", UpsConst.UPS_IN_MEMORY, 0644, param); env.Close(); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_INV_PARAMETER, e.ErrorCode); } }
private void CreateStringIntIntParameter() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); Parameter[] param = new Parameter[1]; param[0] = new Parameter(); param[0].name = UpsConst.UPS_PARAM_CACHESIZE; param[0].value = 1024; try { env.Create("ntest.db", 0, 0644, param); env.Close(); } catch (DatabaseException e) { Assert.Fail("Unexpected exception " + e); } }
private void AutoCleanupCursors4() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); env.Create("ntest.db"); db = env.CreateDatabase(1); Cursor cursor1 = new Cursor(db); Cursor cursor2 = cursor1.Clone(); Cursor cursor3 = cursor1.Clone(); Cursor cursor4 = cursor1.Clone(); Cursor cursor5 = cursor1.Clone(); cursor3.Close(); cursor5.Close(); // let gc do the cleanup env.Close(); }
static void Main(string[] args) { System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); Upscaledb.Environment env = new Upscaledb.Environment(); Database[] db = new Database[3]; Cursor[] cursor = new Cursor[3]; /* * set up the customer and order data - these arrays will later * be inserted into the Databases */ Customer[] customers = new Customer[4]; customers[0] = new Customer(1, "Alan Antonov Corp."); customers[1] = new Customer(2, "Barry Broke Inc."); customers[2] = new Customer(3, "Carl Caesar Lat."); customers[3] = new Customer(4, "Doris Dove Brd."); Order[] orders = new Order[8]; orders[0] = new Order(1, 1, "Joe"); orders[1] = new Order(2, 1, "Tom"); orders[2] = new Order(3, 3, "Joe"); orders[3] = new Order(4, 4, "Tom"); orders[4] = new Order(5, 3, "Ben"); orders[5] = new Order(6, 3, "Ben"); orders[6] = new Order(7, 4, "Chris"); orders[7] = new Order(8, 1, "Ben"); /* * Create a new Environment */ env.Create("test.db"); /* * then create the three Databases in this Environment; each Database * has a name - the first is our "customer" Database, the second * is for the "orders"; the third manages our 1:n relation and * therefore needs to enable duplicate keys */ db[DBIDX_CUSTOMER] = env.CreateDatabase(DBNAME_CUSTOMER); db[DBIDX_ORDER] = env.CreateDatabase(DBNAME_ORDER); db[DBIDX_C2O] = env.CreateDatabase(DBNAME_C2O, UpsConst.UPS_ENABLE_DUPLICATE_KEYS); /* * create a Cursor for each Database */ cursor[DBIDX_CUSTOMER] = new Cursor(db[DBIDX_CUSTOMER]); cursor[DBIDX_ORDER] = new Cursor(db[DBIDX_ORDER]); cursor[DBIDX_C2O] = new Cursor(db[DBIDX_C2O]); /* * Insert the customers in the customer Database * * INSERT INTO customers VALUES (1, "Alan Antonov Corp."); * INSERT INTO customers VALUES (2, "Barry Broke Inc."); * etc. */ for (int i = 0; i < customers.GetLength(0); i++) { byte[] key = customers[i].GetKey(); byte[] rec = customers[i].GetRecord(); db[DBIDX_CUSTOMER].Insert(key, rec); } /* * Insert the orders in the order Database * * INSERT INTO orders VALUES (1, "Joe"); * INSERT INTO orders VALUES (2, "Tom"); * etc. */ for (int i = 0; i < orders.GetLength(0); i++) { byte[] key = orders[i].GetKey(); byte[] rec = orders[i].GetRecord(); db[DBIDX_ORDER].Insert(key, rec); } /* * and now the 1:n relationships; the flag UPS_DUPLICATE creates * a duplicate key, if the key already exists * * INSERT INTO c2o VALUES (1, 1); * INSERT INTO c2o VALUES (2, 1); * etc */ for (int i = 0; i < orders.GetLength(0); i++) { byte[] key = orders[i].GetCustomerKey(); byte[] rec = orders[i].GetKey(); db[DBIDX_C2O].Insert(key, rec, UpsConst.UPS_DUPLICATE); } /* * now start the queries - we want to dump each customer and * his orders * * loop over the customer; for each customer, loop over the * 1:n table and pick those orders with the customer id. * then load the order and print it * * the outer loop is similar to * SELECT * FROM customers WHERE 1; */ while (1 == 1) { Customer c; try { cursor[DBIDX_CUSTOMER].MoveNext(); } catch (DatabaseException e) { // reached end of Database? if (e.ErrorCode == UpsConst.UPS_KEY_NOT_FOUND) break; Console.Out.WriteLine("cursor.MoveNext failed: " + e); return; } // load the customer c = new Customer(cursor[DBIDX_CUSTOMER].GetKey(), cursor[DBIDX_CUSTOMER].GetRecord()); // print information about this customer Console.Out.WriteLine("customer " + c.id + " ('" + c.name + "')"); /* * loop over the 1:n table * * SELECT * FROM customers, orders, c2o * WHERE c2o.customer_id=customers.id AND * c2o.order_id=orders.id; */ try { cursor[DBIDX_C2O].Find(c.GetKey()); } catch (DatabaseException e) { // no order for this customer? if (e.ErrorCode == UpsConst.UPS_KEY_NOT_FOUND) continue; Console.Out.WriteLine("cursor.Find failed: " + e); return; } do { /* * load the order; orderId is a byteArray with the ID of the * Order; the record of the item is a byteArray with the * name of the assigned employee * * SELECT * FROM orders WHERE id = order_id; */ byte[] orderId = cursor[DBIDX_C2O].GetRecord(); cursor[DBIDX_ORDER].Find(orderId); String assignee = enc.GetString(cursor[DBIDX_ORDER].GetRecord()); Console.Out.WriteLine(" order: " + BitConverter.ToInt32(orderId, 0) + " (assigned to " + assignee + ")"); /* * move to the next order of this customer * * the flag UPS_ONLY_DUPLICATES restricts the cursor * movement to the duplicates of the current key. */ try { cursor[DBIDX_C2O].MoveNext(UpsConst.UPS_ONLY_DUPLICATES); } catch (DatabaseException e) { // no more orders for this customer? if (e.ErrorCode == UpsConst.UPS_KEY_NOT_FOUND) break; Console.Out.WriteLine("cursor.MoveNext failed: " + e); return; } } while (1 == 1); } }
private void InsertKeyOverwrite() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r = new byte[5]; try { env.Create("ntest.db"); db = env.CreateDatabase(1); db.Insert(k, r); r[0] = 1; db.Insert(k, r, UpsConst.UPS_OVERWRITE); byte[] r2 = db.Find(k); checkEqual(r, r2); db.Close(); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }
static void Main(string[] args) { byte[] key = new byte[5]; byte[] record = new byte[5]; Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); /* * first, create a new Database */ env.Create("test.db"); db = env.CreateDatabase(1); /* * now we can insert, delete or lookup values in the Database * * for our test program, we just insert a few values, then look them * up, then delete them and try to look them up again (which will fail). */ for (int i = 0; i < LOOP; i++) { key[0] = (byte)i; record[0] = (byte)i; db.Insert(key, record); } /* * now look up all values */ for (int i = 0; i < LOOP; i++) { key[0] = (byte)i; byte[] r = db.Find(key); /* * check if the value is ok */ if (r[0] != (byte)i) { Console.Out.WriteLine("db.Find() returned bad value"); return; } } /* * close the Database handle, then re-open it (just to demonstrate how * to open a Database file) */ db.Close(); env.Close(); env.Open("test.db"); db = env.OpenDatabase(1); /* * now erase all values */ for (int i = 0; i < LOOP; i++) { key[0] = (byte)i; db.Erase(key); } /* * once more we try to find all values... every db.Find() call must * now fail with HAM_KEY_NOT_FOUND */ for (int i = 0; i < LOOP; i++) { key[0] = (byte)i; try { byte[] r = db.Find(key); } catch (DatabaseException e) { if (e.ErrorCode != UpsConst.UPS_KEY_NOT_FOUND) { Console.Out.WriteLine("db.Find() returned error " + e); return; } } } /* * We're done! No need to close the Database handle - it's closed automatically */ Console.Out.WriteLine("Success!"); }
private void EraseKeyTwice() { Upscaledb.Environment env = new Upscaledb.Environment(); Database db = new Database(); byte[] k = new byte[5]; byte[] r = new byte[5]; env.Create("ntest.db"); db = env.CreateDatabase(1); db.Insert(k, r); byte[] r2 = db.Find(k); checkEqual(r, r2); db.Erase(k); try { db.Erase(k); } catch (DatabaseException e) { Assert.AreEqual(UpsConst.UPS_KEY_NOT_FOUND, e.ErrorCode); } db.Close(); env.Close(); }
private void OpenString() { Upscaledb.Environment env = new Upscaledb.Environment(); try { env.Create("ntest.db"); env.Close(); env.Open("ntest.db"); env.Close(); } catch (DatabaseException e) { Assert.Fail("unexpected exception " + e); } }