/// <summary> /// Helper for testing empty dictionary /// </summary> /// <typeparam name="TKey">type of dictionary key</typeparam> /// <typeparam name="TValue">type of dictionary value</typeparam> private static void TestEmptyDictionaty <TKey, TValue>() { // Singleton test var instance1 = Empty.GetDictionary <TKey, TValue>(); Assert.IsNotNull(instance1); var instance2 = Empty.GetDictionary <TKey, TValue>(); Assert.IsNotNull(instance2); Assert.IsTrue(object.ReferenceEquals(instance1, instance2)); // Count Assert.AreEqual(0, instance1.Count); // enumerator var hasValue = false; foreach (var pair in instance1) { hasValue = true; } Assert.IsFalse(hasValue); // cast test Assert.IsNull(instance1 as IDictionary <TKey, TValue>); }