public void TestEnumeratingDictionary() { var dict = new MutableDictionaryObject(); for (int i = 0; i < 20; i++) { dict.SetInt($"key{i}", i); } var content = dict.ToDictionary(); var result = new Dictionary <string, object>(); foreach (var item in dict) { result[item.Key] = item.Value; } result.ShouldBeEquivalentTo(content, "because that is the correct content"); content = dict.Remove("key2").SetInt("key20", 20).SetInt("key21", 21).ToDictionary(); result = new Dictionary <string, object>(); foreach (var item in dict) { result[item.Key] = item.Value; } result.ShouldBeEquivalentTo(content, "because that is the correct content"); var doc = new MutableDocument("doc1"); doc.SetDictionary("dict", dict); SaveDocument(doc, d => { result = new Dictionary <string, object>(); var dictObj = d.GetDictionary("dict"); foreach (var item in dictObj) { result[item.Key] = item.Value; } result.ShouldBeEquivalentTo(content, "because that is the correct content"); }); }