public void TestAppend() { uint recno; testName = "TestAppend"; SetUpTest(true); string dbFileName = testHome + "/" + testName + ".db"; RecnoDatabaseConfig recnoConfig = new RecnoDatabaseConfig(); recnoConfig.Creation = CreatePolicy.IF_NEEDED; recnoConfig.Append = new AppendRecordDelegate( AppendRecord); RecnoDatabase recnoDB = RecnoDatabase.Open( dbFileName, recnoConfig); recno = recnoDB.Append(new DatabaseEntry( ASCIIEncoding.ASCII.GetBytes("data"))); KeyValuePair <DatabaseEntry, DatabaseEntry> pair; pair = recnoDB.Get( new DatabaseEntry(BitConverter.GetBytes(recno))); Assert.AreEqual(ASCIIEncoding.ASCII.GetBytes("data"), pair.Value.Data); recnoDB.Close(); }
public void TestAppendWithoutTxn() { testName = "TestAppendWithoutTxn"; SetUpTest(true); string recnoDBFileName = testHome + "/" + testName + ".db"; RecnoDatabaseConfig recnoConfig = new RecnoDatabaseConfig(); recnoConfig.Creation = CreatePolicy.ALWAYS; RecnoDatabase recnoDB = RecnoDatabase.Open( recnoDBFileName, recnoConfig); DatabaseEntry data = new DatabaseEntry( ASCIIEncoding.ASCII.GetBytes("data")); uint num = recnoDB.Append(data); DatabaseEntry key = new DatabaseEntry( BitConverter.GetBytes(num)); Assert.IsTrue(recnoDB.Exists(key)); KeyValuePair <DatabaseEntry, DatabaseEntry> record = recnoDB.Get(key); Assert.IsTrue(data.Data.Length == record.Value.Data.Length); for (int i = 0; i < data.Data.Length; i++) { Assert.IsTrue(data.Data[i] == record.Value.Data[i]); } recnoDB.Close(); }