public void TestSafeRemove(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.NewItems[0], new KeyValuePair <string, int>("one", 1)); }; Assert.IsTrue(dic.SafeRemove("one")); Assert.IsFalse(dic.SafeRemove("one")); Assert.AreEqual(1, events); if (track) { Assert.AreEqual(3, acc.Records.Count); } else { Assert.AreEqual(0, acc.Records.Count); } }