public async Task Add_SingleItem_KeepsItem()
        {
            var key  = "good";
            var item = new Item();

            var dictionary = new WeakMultiValueDictionary <string, Item>();
            await dictionary.AddAsync(key, item);

            var result = await dictionary.GetAsync(key);

            Assert.Single(result, item);
        }
        public async Task Add_SingleItem_GarbageCollected_RemovesItem()
        {
            var key = "good";

            var dictionary = new WeakMultiValueDictionary <string, Item>();
            await dictionary.AddAsync(key, new Item());

            await TestHelper.ForceGarbageCollectionAsync();

            var result = await dictionary.GetAsync(key);

            Assert.Empty(result);
        }
        public async Task Add_RemoveItem_DoesntKeepItem()
        {
            var key  = "good";
            var item = new Item();

            var dictionary = new WeakMultiValueDictionary <string, Item>();
            await dictionary.AddAsync(key, item);

            await dictionary.RemoveAsync(key, item);

            var result = await dictionary.GetAsync(key);

            Assert.Empty(result);
        }
        public async Task Add_MultipleItems_KeepsItems()
        {
            var key      = "good";
            var expected = GenerateItems(4);

            var dictionary = new WeakMultiValueDictionary <string, Item>();

            foreach (var item in expected)
            {
                await dictionary.AddAsync(key, item);
            }

            var actual = await dictionary.GetAsync(key);

            TestHelper.AssertEquivalent(expected, actual);
        }
        public async Task Add_MultipleItems_GarbageCollected_RemovesItems()
        {
            var key       = "good";
            var expected  = GenerateItems(4);
            var collected = GenerateItems(4);

            var dictionary = new WeakMultiValueDictionary <string, Item>();

            foreach (var item in expected.Union(collected))
            {
                await dictionary.AddAsync(key, item);
            }

            collected = null;
            await TestHelper.ForceGarbageCollectionAsync();

            var actual = await dictionary.GetAsync(key);

            TestHelper.AssertEquivalent(expected, actual);
        }