Esempio n. 1
0
        public void TestContainsValue()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(4, 6);
            Assert.IsTrue(map.ContainsValue(6));
        }
Esempio n. 2
0
        public void TestAdd()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 3);
            Assert.IsTrue(map.ContainsKeyValuePair(new System.Collections.Generic.KeyValuePair <int, int>(2, 3)));
        }
Esempio n. 3
0
        public void TestAddAll()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 5);
            map.Add(2, 4);
            map.Add(2, 3);
            map.Add(1, 5);
            map.Add(1, 6);
            IMultiMap <int, int> map2 = HashMultiMap <int, int> .Create();

            map.Add(7, 5);
            map.Add(7, 4);
            map.Add(7, 3);
            map.Add(8, 5);
            map.Add(8, 6);
            map.AddAll(map2);
            foreach (int key in map2.Keys)
            {
                Assert.IsTrue(map.ContainsKey(key));
                foreach (int value in map2.Get(key))
                {
                    Assert.IsTrue(map.ContainsValue(value));
                }
            }
        }
Esempio n. 4
0
        public void TestContainsKey()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(3, 2);
            Assert.IsTrue(map.ContainsKey(3));
            Assert.IsFalse(map.ContainsKey(45));
        }
Esempio n. 5
0
 public Enumerator(HashMultiMap <TKey, TValue> multimap)
 {
     this.multimap        = multimap;
     this.ver             = multimap.version;
     this.state           = EnumeratorHelper.EnumeratorState.Before;
     this.keyEnumerator   = null;
     this.valueEnumerator = null;
 }
Esempio n. 6
0
        public void TestClear()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            Assert.IsTrue(map.CountPairs == 0);
            map.Add(1, 2);
            map.Clear();
            Assert.IsTrue(map.CountPairs == 0);
        }
Esempio n. 7
0
        public void TestGet()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 3);
            map.Add(2, 4);
            map.Add(2, 5);
            foreach (int item in map.Get(2))
            {
                Assert.IsTrue(item == 3 || item == 4 || item == 5);
            }
        }
Esempio n. 8
0
        public void TestGetSet()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 3);
            map.Add(2, 4);
            map.Add(2, 5);
            System.Collections.Generic.ISet <int> set = map.GetSet(2);
            Assert.IsTrue(set.Contains(3));
            Assert.IsTrue(set.Contains(4));
            Assert.IsTrue(set.Contains(5));
        }
Esempio n. 9
0
        public void TestCountPair()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(1, 3);
            map.Add(2, 3);
            map.Add(3, 4);
            map.Add(4, 5);
            map.Add(5, 6);
            Assert.IsTrue(map.CountPairs == 5);
            map.Clear();
            Assert.IsTrue(map.CountPairs == 0);
        }
Esempio n. 10
0
        public void TestCountPairs()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 3);
            map.Add(2, 4);
            map.Add(2, 5);
            map.Add(7, 8);
            map.Add(7, 5);
            map.Add(1, 5);
            map.Add(29, 5);
            Assert.IsTrue(map.CountPairs == 7);
        }
Esempio n. 11
0
        public void TestRemoveAll()
        {
            IMultiMap <int, int> map = HashMultiMap <int, int> .Create();

            map.Add(2, 3);
            map.Add(2, 4);
            map.Add(2, 5);
            map.RemoveAll(2);
            Assert.IsFalse(map.ContainsKey(2));
            Assert.IsFalse(map.ContainsValue(4));
            Assert.IsFalse(map.ContainsValue(5));
            Assert.IsFalse(map.ContainsValue(3));
        }