public void TestTryGetValueAndRemoveKey(bool track) { var events = 0; var acc = new Accumulator("test"); var dic = new TrackableDictionary <string, int>(acc, track) { { "one", 1 }, { "two", 2 } }; dic.CollectionChanged += (s, e) => { events++; Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Remove); Assert.AreEqual(e.OldItems[0], new KeyValuePair <string, int>("one", 1)); }; Assert.IsTrue(dic.TryGetValueAndRemoveKey("one", out var val)); Assert.AreEqual(1, val); Assert.IsFalse(dic.ContainsKey("one")); Assert.AreEqual(1, events); if (track) { Assert.AreEqual(3, acc.Records.Count); } else { Assert.AreEqual(0, acc.Records.Count); } }