public void Basics_Remove() { var d = new TransactionalDictionary <int, int> { { 42, 43 } // Add }; Assert.IsTrue(d.Remove(42)); Assert.IsFalse(d.ContainsKey(42)); Assert.IsFalse(d.TryGetValue(42, out var _)); Assert.ThrowsException <KeyNotFoundException>(() => _ = d[42]); Assert.IsFalse(d.Any()); }
public void Basics_Empty() { var d = new TransactionalDictionary <int, int>(); Assert.IsFalse(d.ContainsKey(0)); Assert.IsFalse(d.ContainsKey(1)); Assert.IsFalse(d.ContainsKey(2)); Assert.IsFalse(d.TryGetValue(0, out _)); Assert.IsFalse(d.TryGetValue(1, out _)); Assert.IsFalse(d.TryGetValue(2, out _)); Assert.ThrowsException <KeyNotFoundException>(() => _ = d[0]); Assert.ThrowsException <KeyNotFoundException>(() => _ = d[1]); Assert.ThrowsException <KeyNotFoundException>(() => _ = d[2]); Assert.IsFalse(d.Any()); Assert.IsFalse(d.Remove(0)); Assert.IsFalse(d.Remove(1)); Assert.IsFalse(d.Remove(2)); }