コード例 #1
0
        public void Dictionary_Generic_ContainsValue_Present(int count)
        {
            PooledDictionary <TKey, TValue> dictionary = (PooledDictionary <TKey, TValue>)GenericIDictionaryFactory(count);
            int seed = 4315;
            KeyValuePair <TKey, TValue> notPresent = CreateT(seed++);

            while (dictionary.Contains(notPresent))
            {
                notPresent = CreateT(seed++);
            }
            dictionary.Add(notPresent.Key, notPresent.Value);
            Assert.True(dictionary.ContainsValue(notPresent.Value));
        }
コード例 #2
0
        public void TestReplace()
        {
            using var dict = new PooledDictionary <string, string>();

            dict["one"] = "One";
            dict["one"] = "Two";

            Assert.True(dict.ContainsKey("one"));

#pragma warning disable xUnit2017
            Assert.True(dict.Contains(new KeyValuePair <string, string>("one", "Two")));
#pragma warning restore

            Assert.Equal("Two", dict["one"]);
        }