public void RemoveAll() { //**************************************** var Random = Initialise(); var Records = new StringKeyDictionary <int>(); var Dictionary = new Dictionary <string, int>(1024); //**************************************** foreach (var Pair in YieldRandom(Random, 1024)) { Dictionary.Add(Pair.Key, Pair.Value); Records.Add(Pair.Key, Pair.Value); } //**************************************** Records.RemoveAll((pair) => { if (Random.Next() > int.MaxValue / 2) { return(Dictionary.Remove(pair.Key)); } return(false); }); //**************************************** CollectionAssert.AreEquivalent(Dictionary, Records, "Collections don't match"); foreach (var MyPair in Dictionary) { Assert.IsTrue(Records.TryGetValue(MyPair.Key, out var Value)); Assert.AreEqual(MyPair.Value, Value); } Thread.Sleep(1); }