コード例 #1
0
        private static void BulkDuplicateRead(BerkeleyBulkDuplicateCursor cursor, HashSet<KeyValuePair<int, DateTime>> data, bool blobExists)
        {
            var checkData = new HashSet<KeyValuePair<int, DateTime>>(data);
            bool blobFound = false;
            DateTime d1 = new DateTime(2014, 1, 1);

            foreach (int keyIndex in data.Select(d => d.Key).Distinct())
            {
                Byte[] key = Encoding.UTF8.GetBytes(keyIndex.ToString());
                for (BerkeleyBulkEnumerator buffer = cursor.ReadAsync(key, BerkeleyDbOperation.DB_SET).Result;
                    !buffer.NotFound;
                    buffer = cursor.ReadAsync(null, BerkeleyDbOperation.DB_NEXT_DUP).Result)
                {
                    buffer.Error.ThrowIfError();

                    foreach (BerkeleyKeyValueBulk keyValue in buffer)
                    {
                        String value = Encoding.UTF8.GetString(keyValue.Value.ToArray());
                        DateTime d;
                        if (DateTime.TryParseExact(value, "dddd dd MMMM yyyy", null, DateTimeStyles.None, out d))
                            Assert.IsTrue(checkData.Remove(new KeyValuePair<int, DateTime>(keyIndex, d)), "key/value: " + "key" + keyIndex + "/" + value + " not exists");
                        else
                        {
                            blobFound = keyValue.Value.Count == 34123 && CheckByteArray(keyValue.Value);
                            Assert.IsTrue(blobFound, "blod data is bad");
                        }
                    }
                }
            }

            Assert.AreEqual(checkData.Count, 0, "not all values found");
            Assert.IsTrue(blobFound == blobExists, "blob value not found");
        }