From 0195b3428905fc689084a38e851c26d4033225d6 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Thu, 1 Mar 2012 14:48:53 +0000 Subject: [PATCH] The Count property of the multi dictionary now returns either the value count of the number of unique keys depending on which interface it is called from git-svn-id: file:///srv/devel/repo-conversion/nusu@259 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/Collections/MultiDictionary.Interfaces.cs | 7 +++++++ Source/Collections/MultiDictionary.Test.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Source/Collections/MultiDictionary.Interfaces.cs b/Source/Collections/MultiDictionary.Interfaces.cs index c5b0794..86c1a1e 100644 --- a/Source/Collections/MultiDictionary.Interfaces.cs +++ b/Source/Collections/MultiDictionary.Interfaces.cs @@ -241,6 +241,13 @@ namespace Nuclex.Support.Collections { return this.typedDictionary.GetEnumerator(); } + /// Removes the specified key/value pair from the dictionary + /// Key/value pair that will be removed + /// True if the key/value pair was contained in the dictionary + int ICollection>>.Count { + get { return this.typedDictionary.Count; } + } + #endregion // ICollection>> implementation } diff --git a/Source/Collections/MultiDictionary.Test.cs b/Source/Collections/MultiDictionary.Test.cs index 15a1fa4..19310bc 100644 --- a/Source/Collections/MultiDictionary.Test.cs +++ b/Source/Collections/MultiDictionary.Test.cs @@ -139,6 +139,21 @@ namespace Nuclex.Support.Collections { ); } + /// + /// Verifies that the Count property returns the number of unique keys if it is called + /// on the collection-of-collections interface implemented by the multi dictionary + /// + [Test] + public void CollectionOfCollectionCountIsUniqueKeyCount() { + var dictionary = new MultiDictionary(); + dictionary.Add(10, "ten"); + dictionary.Add(10, "zehn"); + + Assert.AreEqual(2, dictionary.Count); + var collectionOfCollections = (ICollection>>)dictionary; + Assert.AreEqual(1, collectionOfCollections.Count); + } + } } // namespace Nuclex.Support.Collections