public virtual void Add_InsertKeyValue_IndexAddStrategy_Replace() { #region data var idx = new BinaryTreeIndex(); var key_1 = 1; var val_1 = 1; var val_2 = 2; #endregion #region test // insert first key value idx.Add(key_1, val_1, IndexAddStrategy.MERGE); // index must contain key and one value Assert.IsTrue(idx[key_1].Contains(val_1)); Assert.AreEqual(1, idx[key_1].Count()); // idx value count Assert.AreEqual(1, idx.ValueCount()); // replace first value by the second idx.Add(1, val_2, IndexAddStrategy.REPLACE); // index now contains the new value for the key Assert.IsTrue(idx[key_1].Contains(val_2)); Assert.AreEqual(1, idx[key_1].Count()); // idx value count Assert.AreEqual(1, idx.ValueCount()); idx.Clear(); #endregion }
public virtual void Clear_RemoveAllKeys() { #region data var n = 10; var idx = new BinaryTreeIndex(); var vertices = CreateKeyValuePairs(n); #endregion #region test idx.AddRange(vertices); Assert.That(idx.KeyCount(), Is.EqualTo(n)); Assert.That(idx.ValueCount(), Is.EqualTo(n)); idx.Clear(); Assert.That(idx.KeyCount(), Is.EqualTo(0)); Assert.That(idx.ValueCount(), Is.EqualTo(0)); #endregion }
public virtual void Add_InsertKeyValue_IndexAddStrategy_Merge() { #region data var idx = new BinaryTreeIndex(); var key_1 = 1; var val_1 = 1; var val_2 = 2; #endregion #region test // insert first key value idx.Add(key_1, val_1, IndexAddStrategy.MERGE); // index must contain key and one value Assert.IsTrue(idx[key_1].Contains(val_1)); Assert.AreEqual(1, idx[key_1].Count()); // merge a second value with the currently stored one idx.Add(key_1, val_2, IndexAddStrategy.MERGE); // index now contains two values for the key Assert.IsTrue(idx[1].Contains(val_1)); Assert.IsTrue(idx[1].Contains(val_2)); Assert.AreEqual(2, idx[1].Count()); idx.Clear(); #endregion }