public virtual void TryRemoveValue_NonExistingKey_NonExistingValue() { #region data var idx = new BinaryTreeIndex(); var key_1 = 1; var key_2 = 2; var val_1 = 1; var val_2 = 2; #endregion #region test idx.Add(key_1, val_1); // counter Assert.That(idx.KeyCount(), Is.EqualTo(1)); Assert.That(idx.ValueCount(), Is.EqualTo(1)); // try to remove existing value (only one value, this means the index has to be deleted too) Assert.IsFalse(idx.TryRemoveValue(key_2, val_2)); Assert.That(idx.KeyCount(), Is.EqualTo(1)); Assert.That(idx.ValueCount(), Is.EqualTo(1)); #endregion }
public virtual void TryRemoveValue_ExistingKey_ExistingValue() { #region data var idx = new BinaryTreeIndex(); var key_1 = 1; var val_1 = 1; var val_2 = 2; #endregion #region test idx.Add(key_1, val_1); // counter Assert.That(idx.KeyCount(), Is.EqualTo(1)); Assert.That(idx.ValueCount(), Is.EqualTo(1)); // try to remove existing value (only one value, this means the index has to be deleted too) Assert.IsTrue(idx.TryRemoveValue(key_1, val_1)); Assert.That(idx.KeyCount(), Is.EqualTo(0)); Assert.That(idx.ValueCount(), Is.EqualTo(0)); // add two values for one key idx.Add(key_1, val_1); idx.Add(key_1, val_2, IndexAddStrategy.MERGE); Assert.That(idx.KeyCount(), Is.EqualTo(1)); Assert.That(idx.ValueCount(), Is.EqualTo(2)); // remove one value Assert.That(idx.TryRemoveValue(key_1, val_1), Is.True); Assert.That(idx.KeyCount(), Is.EqualTo(1)); Assert.That(idx.ValueCount(), Is.EqualTo(1)); Assert.That(idx[key_1].Contains(val_2), Is.True); Assert.That(idx[key_1].LongCount(), Is.EqualTo(1)); #endregion }