/// <summary>
        /// Test dictionary insert/replace/delete.
        /// </summary>
        /// <typeparam name="TKey">Key type of the dictionary.</typeparam>
        /// <typeparam name="TValue">Value type of the dictionary.</typeparam>
        /// <param name="dictionary">The dictionary to test.</param>
        /// <param name="key">Key that is present in the dictionary.</param>
        /// <param name="value">Value associated with the key in the dictionary.</param>
        private static void TestBasicOperations <TKey, TValue>(PersistentDictionary <TKey, TValue> dictionary, TKey key, TValue value)
            where TKey : IComparable <TKey>
        {
            var kvp = new KeyValuePair <TKey, TValue>(key, value);

            // Add a record
            dictionary.Add(key, value);

            // Test PersistentDictionary.Add error handling
            try
            {
                dictionary.Add(key, value);
                Assert.Fail("Expected ArgumentException from Add");
            }
            catch (ArgumentException)
            {
                // Expected
            }

            // Overwrite a value
            dictionary[key] = value;

            // Retrieve a value
            Assert.AreEqual(value, dictionary[key], "Retrieve with [] failed");
            TValue t;

            Assert.IsTrue(dictionary.TryGetValue(key, out t), "TryGetValue({0}) failed", key);
            Assert.AreEqual(value, t, "TryGetValue({0}) returned the wrong value", key);

            // Clear and re-insert
            dictionary.Clear();
            Assert.AreEqual(0, dictionary.Count, "Dictionary is empty. Count is wrong");
            dictionary[key] = value;
            Assert.AreEqual(1, dictionary.Count, "Item was just inserted. Count is wrong");

            // Get the keys and values
            Assert.AreEqual(dictionary.Keys.First(), key, "Keys collection");
            Assert.AreEqual(dictionary.Values.First(), value, "Values collection");

            // Test PersistentDictionary.Contains (true)
            Assert.IsTrue(dictionary.ContainsKey(key), "Dictionary should have contained key {0}", key);
            Assert.IsTrue(dictionary.ContainsValue(value), "Dictionary should have contained value {0}", value);
            Assert.IsTrue(dictionary.Contains(kvp), "Dictionary should have contained <{0},{1}>", key, value);

            // Test PersistentDictionary.Remove
            Assert.IsTrue(dictionary.Remove(key), "Key {0} should exist, but removal failed", key);
            Assert.IsFalse(dictionary.Remove(key), "Key {0} doesn't exist, but removal succeeded", key);

            dictionary.Add(kvp);
            Assert.IsTrue(dictionary.Remove(kvp), "KeyValuePair <{0},{1}> should exist, but removal failed", kvp.Key, kvp.Value);
            Assert.IsFalse(dictionary.Remove(kvp), "KeyValuePair <{0},{1}> doesn't exist, but removal succeeded", kvp.Key, kvp.Value);

            // Test PersistentDictionary.Contains (false)
            Assert.IsFalse(dictionary.ContainsKey(key), "Dictionary should have contained key {0}", key);
            Assert.IsFalse(dictionary.ContainsValue(value), "Dictionary should have contained value {0}", value);
            Assert.IsFalse(dictionary.Contains(kvp), "Dictionary should have contained <{0},{1}>", key, value);
        }