public void ValuesCollectionRemoveGuardTest() { HashMapDataValue value = new HashMapDataValue("val1"); this.hashMap.Add(new HashMapDataKey(1), value); this.hashMap.Values.Remove(value); }
public void ValuesCollectionCopyToGuardCase3Test() { HashMapDataValue[] values = new HashMapDataValue[4]; this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("val1")); this.hashMap.Add(new HashMapDataKey(2), new HashMapDataValue("val2")); this.hashMap.Values.CopyTo(values, 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 ValuesCollectionCopyToTest() { HashMapDataValue[] values = new HashMapDataValue[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.Values.CopyTo(values, 5); HashMapDataValue[] expectedValues = new HashMapDataValue[] { null, null, null, null, null, new HashMapDataValue("val1"), new HashMapDataValue("val2"), new HashMapDataValue("val3") }; CollectionAssertEx.AreEquivalent(expectedValues, values); }
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 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 ValuesCollectionEnumeratorTest() { 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 <HashMapDataValue> valueList = new List <HashMapDataValue>(4); foreach (var value in this.hashMap.Values) { valueList.Add(value); } HashMapDataValue[] expectedValues = new HashMapDataValue[] { new HashMapDataValue("val1"), new HashMapDataValue("val2"), new HashMapDataValue("val3") }; CollectionAssertEx.AreEquivalent(expectedValues, valueList); }
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 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 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 override bool Equals(object obj) { HashMapDataValue other = obj as HashMapDataValue; return(other != null && Equals(Value, other.Value)); }
public void GetIndexerGuardCase1Test() { this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("1")); HashMapDataValue result = this.hashMap[null]; }
public void GetIndexerGuardCase2Test() { this.hashMap.Add(new HashMapDataKey(1), new HashMapDataValue("1")); this.hashMap.Add(new HashMapDataKey(2), new HashMapDataValue("2")); HashMapDataValue result = this.hashMap[new HashMapDataKey(3)]; }