public void KeysCollectionRemoveGuardTest()
        {
            HashMapDataKey key = new HashMapDataKey(1);

            this.hashMap.Add(key, new HashMapDataValue("val1"));
            this.hashMap.Keys.Remove(key);
        }
        public void GetOrAddGuardCase2Test()
        {
            HashMapDataKey key = new HashMapDataKey(1);

            this.hashMap.Add(key, new HashMapDataValue("1"));
            this.hashMap.GetOrAdd(key, null);
        }
 public void KeysCollectionCopyToGuardCase3Test()
 {
     HashMapDataKey[] keys = new HashMapDataKey[4];
     this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("val1"));
     this.hashMap.Add(new HashMapDataKey(2), new HashMapDataValue("val2"));
     this.hashMap.Keys.CopyTo(keys, 4);
 }
        public void GetIndexerTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);

            Assert.AreEqual(val1, this.hashMap[new HashMapDataKey(1)]);
            Assert.AreEqual(val2, this.hashMap[key2]);
        }
 public void KeysCollectionCopyToTest()
 {
     HashMapDataKey[] keys = new HashMapDataKey[8];
     this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("val1"));
     this.hashMap.Add(new HashMapDataKey(2), new HashMapDataValue("val2"));
     this.hashMap.Add(new HashMapDataKey(3), new HashMapDataValue("val3"));
     this.hashMap.Keys.CopyTo(keys, 5);
     HashMapDataKey[] expectedKeys = new HashMapDataKey[] {
         null, null, null, null, null,
         new HashMapDataKey(1),
         new HashMapDataKey(2),
         new HashMapDataKey(3)
     };
     CollectionAssertEx.AreEquivalent(expectedKeys, keys);
 }
        public void AddTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.Add(key3, val3);
            this.hashMap.AssertKeys(key1, key2, key3).AssertValues(val1, val2, val3);
        }
        public void SetIndexerTest1()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap[key1] = val3;
            this.hashMap.AssertKeys(key1, key2).AssertValues(val3, val2);
            Assert.AreEqual(val3, this.hashMap[key1]);
        }
        public void SetIndexerTest2()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.AssertKeys(key1, key2).AssertValues(val1, val2);
            this.hashMap[key3] = val3;
            this.hashMap.AssertKeys(key1, key2, key3).AssertValues(val1, val2, val3);
        }
        public void ContainsKeyTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            Assert.IsTrue(this.hashMap.ContainsKey(new HashMapDataKey(1)));
            Assert.IsFalse(this.hashMap.ContainsKey(new HashMapDataKey(3)));
            Assert.IsTrue(this.hashMap.ContainsKey(key2));
            Assert.IsFalse(this.hashMap.ContainsKey(key3));
        }
        public void ClearTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            CollectionAssertEx.IsNotEmpty(this.hashMap.Keys);
            CollectionAssertEx.IsNotEmpty(this.hashMap.Values);

            this.hashMap.Clear();
            CollectionAssertEx.IsEmpty(this.hashMap.Keys);
            CollectionAssertEx.IsEmpty(this.hashMap.Values);
        }
        public void KeysCollectionEnumeratorTest()
        {
            this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("val1"));
            this.hashMap.Add(new HashMapDataKey(2), new HashMapDataValue("val2"));
            this.hashMap.Add(new HashMapDataKey(3), new HashMapDataValue("val3"));
            List <HashMapDataKey> keyList = new List <HashMapDataKey>(4);

            foreach (var key in this.hashMap.Keys)
            {
                keyList.Add(key);
            }
            HashMapDataKey[] expectedKeys = new HashMapDataKey[] {
                new HashMapDataKey(1),
                new HashMapDataKey(2),
                new HashMapDataKey(3)
            };
            CollectionAssertEx.AreEquivalent(expectedKeys, keyList);
        }
        public void ContainsValueTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.Add(key3, null);
            Assert.IsTrue(this.hashMap.ContainsValue(new HashMapDataValue("val1")));
            Assert.IsFalse(this.hashMap.ContainsValue(new HashMapDataValue("val4")));
            Assert.IsTrue(this.hashMap.ContainsValue(null));
            Assert.IsFalse(this.hashMap.ContainsValue(val3));
        }
        public void CountTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.Add(key3, val3);
            Assert.AreEqual(3, this.hashMap.Count);

            this.hashMap.Remove(new HashMapDataKey(2));
            Assert.AreEqual(2, this.hashMap.Count);
            this.hashMap.Clear();
            Assert.AreEqual(0, this.hashMap.Count);
        }
        public void GetOrAddTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.AssertKeys(key1, key2).AssertValues(val1, val2);

            Assert.AreSame(val1, this.hashMap.GetOrAdd(key1, x => val3));
            Assert.AreSame(val2, this.hashMap.GetOrAdd(key2, x => val3));
            this.hashMap.AssertKeys(key1, key2).AssertValues(val1, val2);

            Assert.AreSame(val3, this.hashMap.GetOrAdd(key3, x => val3));
            this.hashMap.AssertKeys(key1, key2, key3).AssertValues(val1, val2, val3);
        }
        public void RemoveTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");
            HashMapDataValue val3 = new HashMapDataValue("val3");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);
            this.hashMap.Add(key3, val3);

            Assert.IsTrue(this.hashMap.Remove(new HashMapDataKey(3)));
            this.hashMap.AssertKeys(key1, key2).AssertValues(val1, val2);

            Assert.IsFalse(this.hashMap.Remove(new HashMapDataKey(4)));
            this.hashMap.AssertKeys(key1, key2).AssertValues(val1, val2);

            Assert.IsTrue(this.hashMap.Remove(key1));
            this.hashMap.AssertKeys(key2).AssertValues(val2);
        }
        public void TryGetValueTest()
        {
            HashMapDataKey key1 = new HashMapDataKey(1);
            HashMapDataKey key2 = new HashMapDataKey(2);
            HashMapDataKey key3 = new HashMapDataKey(3);

            HashMapDataValue val1 = new HashMapDataValue("val1");
            HashMapDataValue val2 = new HashMapDataValue("val2");

            this.hashMap.Add(key1, val1);
            this.hashMap.Add(key2, val2);

            HashMapDataValue value;

            Assert.IsTrue(this.hashMap.TryGetValue(key2, out value));
            Assert.AreSame(val2, value);
            Assert.IsTrue(this.hashMap.TryGetValue(key2, out value));
            Assert.AreSame(val2, value);
            Assert.IsFalse(this.hashMap.TryGetValue(key3, out value));
            Assert.IsNull(value);
            Assert.IsTrue(this.hashMap.TryGetValue(new HashMapDataKey(1), out value));
            Assert.AreSame(val1, value);
        }
        public override bool Equals(object obj)
        {
            HashMapDataKey other = obj as HashMapDataKey;

            return(other != null && ID == other.ID);
        }