コード例 #1
0
        public void TestDeleteMultipleKey()
        {
            testName = "TestDeleteMultipleKey";
            SetUpTest(true);

            QueueDatabaseConfig dbConfig = new QueueDatabaseConfig();

            dbConfig.Creation   = CreatePolicy.IF_NEEDED;
            dbConfig.ExtentSize = 1024;
            dbConfig.Length     = 520;
            QueueDatabase db = QueueDatabase.Open(testHome + "/" +
                                                  testName + ".db", dbConfig);

            List <KeyValuePair <DatabaseEntry, DatabaseEntry> > pList =
                new List <KeyValuePair <DatabaseEntry, DatabaseEntry> >();
            DatabaseEntry key, data;

            for (uint i = 1; i <= 100; i++)
            {
                key = new DatabaseEntry(
                    BitConverter.GetBytes(i));
                data = new DatabaseEntry(
                    ASCIIEncoding.ASCII.GetBytes(
                        "data" + i.ToString() +
                        Configuration.RandomString(512)));
                pList.Add(new KeyValuePair <
                              DatabaseEntry, DatabaseEntry>(key, data));
                db.Put(key, data);
            }

            // Create key/value pair bulk buffer and delete all.
            db.Delete(new MultipleKeyDatabaseEntry(pList, true));
            // Verify that the database is empty.
            Assert.AreEqual(0, db.Truncate());
            db.Close();
        }