public void EnumerationWorksAfterConflictingKvpInsert()
        {
            var orderedDictionary = DictionaryTesting.CreateOrderedDictionary(0);
            var kvp = KeyValuePair.Create(1, 1);

            orderedDictionary.Add(kvp);
            Assert.Throws <ArgumentException>(() => orderedDictionary.Add(kvp));
            var orderedCount = orderedDictionary.Count(_ => true);

            Assert.AreEqual(1, orderedCount);
        }
        public void IsContainsKvpOptimallyImplemented()
        {
            var       kvp      = KeyValuePair.Create(1, 1);
            const int Capacity = 1000000;
            Action <IDictionary <int, int> > act = d => d.Contains(kvp);
            var orderedDictionaryCount           = DictionaryTesting.TestPerformance(
                () => DictionaryTesting.CreateOrderedDictionary(Capacity),
                act);
            var referenceDictionaryCount = DictionaryTesting.TestPerformance(
                () => DictionaryTesting.CreateReferenceDictionary(Capacity),
                act);

            Assert.AreEqual(
                orderedDictionaryCount,
                referenceDictionaryCount,
                referenceDictionaryCount * 0.08,
                "The time-based test performance for Contains(KeyValuePair<,>) in ordered dictionary deviates from reference one too much.");
        }