Exemple #1
0
        public void Array3LiteDictionaryTest()
        {
            LiteDictionary ld = new LiteDictionary();

            ld.Add("key1", "value1");
            ld.Add("key2", "value2");
            ld.Add("key3", "value3");

            Assert.AreEqual(ld.Count, 3);
            Assert.IsFalse(ld.IsEmpty);
            Assert.IsTrue(ld.Contains("key1"));
            Assert.IsFalse(ld.Contains("dummy"));
            Assert.AreEqual(ld.Keys.Count, 3);
            Assert.AreEqual(ld.Values.Count, 3);
            Assert.AreEqual(ld["key1"], "value1");
            ld["key1"] = "new value1";
            Assert.AreEqual(ld["key1"], "new value1");
            foreach (object o in ld)
            {
                Assert.IsInstanceOf(typeof(DictionaryEntry), o);
            }

            object[] array = new object[3];
            ld.CopyTo(array, 0);
            Assert.AreEqual(array.Length, ld.Count);
            Assert.IsInstanceOf(typeof(DictionaryEntry), array[0]);
            ld.Remove("key1");
            Assert.AreEqual(ld.Count, 2);
        }
Exemple #2
0
        public void SingleLiteDictionaryTest()
        {
            LiteDictionary ld = new LiteDictionary();

            ld.Add("key", "value");

            Assert.AreEqual(ld.Count, 1);
            Assert.IsFalse(ld.IsEmpty);
            Assert.IsTrue(ld.Contains("key"));
            Assert.IsFalse(ld.Contains("dummy"));
            Assert.AreEqual(ld.Keys.Count, 1);
            Assert.AreEqual(ld.Values.Count, 1);
            Assert.AreEqual(ld["key"], "value");
            ld["key"] = "new value";
            Assert.AreEqual(ld["key"], "new value");
            foreach (object o in ld)
            {
                Assert.IsInstanceOf(typeof(DictionaryEntry), o);
            }

            object[] array = new object[1];
            ld.CopyTo(array, 0);
            Assert.AreEqual(array.Length, ld.Count);
            Assert.IsInstanceOf(typeof(DictionaryEntry), array[0]);
            Assert.AreEqual(((DictionaryEntry)array[0]).Value, ld["key"]);
            ld.Remove("key");
            Assert.AreEqual(ld.Count, 0);
        }
Exemple #3
0
        public void GrowingAndShrinkingLiteDictionaryTest()
        {
            LiteDictionary ld = new LiteDictionary();

            ld.Add(1, 1);
            ld.Add(2, 2);
            ld.Add(3, 3);
            ld.Add(4, 4);
            ld.Add(5, 5);
            ld.Add(6, 6);
            ld.Add(7, 7);
            ld.Remove(7);
            ld.Add(8, 8);
            ld.Add(9, 9);
            ld.Add(10, 10);
        }
Exemple #4
0
        public void TestForCOH2353()
        {
            LiteDictionary ld = new LiteDictionary();

            ld.Add(1, 1);
            ld.Add(2, 2);
            ld.Add(3, 3);
            ld.Add(null, 4);
            ld.Add(5, 5);
            ld.Add(6, 6);
            ld.Add(7, 7);
            ld.Remove(7);
            ld.Add(8, 8);
            ld.Add(9, 9);
            ld.Add(10, 10);

            Assert.IsTrue(ld.Contains(null));
        }