Esempio n. 1
0
        public void TestConsumeWithoutTxn()
        {
            testName = "TestConsumeWithoutTxn";
            testHome = testFixtureHome + "/" + testName;
            string queueDBFileName = testHome + "/" +
                                     testName + ".db";

            Configuration.ClearDir(testHome);

            QueueDatabaseConfig queueConfig =
                new QueueDatabaseConfig();

            queueConfig.Creation    = CreatePolicy.ALWAYS;
            queueConfig.ErrorPrefix = testName;
            queueConfig.Length      = 1000;

            QueueDatabase queueDB = QueueDatabase.Open(
                queueDBFileName, queueConfig);
            DatabaseEntry data = new DatabaseEntry(
                ASCIIEncoding.ASCII.GetBytes("data"));

            queueDB.Append(data);

            DatabaseEntry consumeData = new DatabaseEntry();
            KeyValuePair <uint, DatabaseEntry> pair = queueDB.Consume(false);

            try
            {
                DatabaseEntry key =
                    new DatabaseEntry(BitConverter.GetBytes(pair.Key));
                queueDB.Get(key);
            }
            catch (NotFoundException)
            {
                throw new ExpectedTestException();
            }
            finally
            {
                queueDB.Close();
            }
        }