Example #1
0
        public void SynchronizedDictionaryUnitTest()
        {
            SynchronizedDictionary<int, string> dictionary = new SynchronizedDictionary<int, string>();

            dictionary.Add(1, "one");
            dictionary.Add(2, "two");
            Assert.IsTrue(dictionary.Count == 2);

            foreach (KeyValuePair<int, string> keyValuePair in dictionary)
            {
                Assert.IsTrue(dictionary.ContainsKey(keyValuePair.Key));
                Assert.IsTrue(dictionary.ContainsValue(keyValuePair.Value));
            }

            dictionary.Remove(1);
            Assert.IsTrue(dictionary.Count == 1);

            dictionary.Clear();
            Assert.IsTrue(dictionary.Count == 0);
        }