コード例 #1
0
        public void ClearItems_WithDictionary_Success()
        {
            var collection = new StringKeyedCollection <string>(null, 3);

            collection.GetKeyForItemHandler = item => item + "_key";
            collection.Add("first");
            collection.Add("second");
            collection.Add("third");
            collection.Add("fourth");
            Assert.NotNull(collection.Dictionary);

            collection.ClearItems();
            Assert.Empty(collection);
            Assert.Empty(collection.Dictionary);
        }
コード例 #2
0
        public void ClearItems_Invoke_ResetsCurrentThresholdCount()
        {
            var collection = new StringKeyedCollection <string>(null, 3);

            collection.GetKeyForItemHandler = item => item + "_key";
            collection.Add("first");
            collection.ClearItems();

            // Add more items - make sure the current count has been reset.
            collection.Add("first");
            Assert.Null(collection.Dictionary);

            collection.Add("second");
            Assert.Null(collection.Dictionary);

            collection.Add("third");
            Assert.Null(collection.Dictionary);

            collection.Add("fourth");
            Assert.NotEmpty(collection.Dictionary);
        }