public void TestGetValueFromNewEmptyDictionary()
        {
            DictionaryObject dict = new MutableDictionaryObject();

            dict.GetInt("key").Should().Be(0, "because that is the default value");
            dict.GetLong("key").Should().Be(0L, "because that is the default value");
            dict.GetDouble("key").Should().Be(0.0, "because that is the default value");
            dict.GetBoolean("key").Should().Be(false, "because that is the default value");
            dict.GetDate("key").Should().Be(DateTimeOffset.MinValue, "because that is the default value");
            dict.GetBlob("key").Should().BeNull("because that is the default value");
            dict.GetValue("key").Should().BeNull("because that is the default value");
            dict.GetString("key").Should().BeNull("because that is the default value");
            dict.GetDictionary("key").Should().BeNull("because that is the default value");
            dict.GetArray("key").Should().BeNull("because that is the default value");
            dict.ToDictionary().Should().BeEmpty("because the dictionary is empty");

            var doc = new MutableDocument("doc1");

            doc.SetDictionary("dict", dict);

            Db.Save(doc);
            var gotDoc = Db.GetDocument("doc1");

            dict = gotDoc.GetDictionary("dict");
            dict.GetInt("key").Should().Be(0, "because that is the default value");
            dict.GetLong("key").Should().Be(0L, "because that is the default value");
            dict.GetDouble("key").Should().Be(0.0, "because that is the default value");
            dict.GetBoolean("key").Should().Be(false, "because that is the default value");
            dict.GetDate("key").Should().Be(DateTimeOffset.MinValue, "because that is the default value");
            dict.GetBlob("key").Should().BeNull("because that is the default value");
            dict.GetValue("key").Should().BeNull("because that is the default value");
            dict.GetString("key").Should().BeNull("because that is the default value");
            dict.GetDictionary("key").Should().BeNull("because that is the default value");
            dict.GetArray("key").Should().BeNull("because that is the default value");
            dict.ToDictionary().Should().BeEmpty("because the dictionary is empty");
        }
        public void TestSetNestedDictionaries()
        {
            var doc    = new MutableDocument("doc1");
            var level1 = new MutableDictionaryObject();

            level1.SetString("name", "n1");
            doc.SetDictionary("level1", level1);

            var level2 = new MutableDictionaryObject();

            level2.SetString("name", "n2");
            level1.SetDictionary("level2", level2);

            var level3 = new MutableDictionaryObject();

            level3.SetString("name", "n3");
            level2.SetDictionary("level3", level3);

            doc.GetDictionary("level1").ShouldBeEquivalentTo(level1, "because that is what was inserted");
            level1.GetDictionary("level2").ShouldBeEquivalentTo(level2, "because that is what was inserted");
            level2.GetDictionary("level3").ShouldBeEquivalentTo(level3, "because that is what was inserted");
            var dict = new Dictionary <string, object> {
                ["level1"] = new Dictionary <string, object> {
                    ["name"]   = "n1",
                    ["level2"] = new Dictionary <string, object> {
                        ["name"]   = "n2",
                        ["level3"] = new Dictionary <string, object> {
                            ["name"] = "n3"
                        }
                    }
                }
            };

            doc.ToDictionary().ShouldBeEquivalentTo(dict, "because otherwise the document's contents are incorrect");

            Db.Save(doc);
            var gotDoc = Db.GetDocument("doc1");

            gotDoc.GetDictionary("level1").Should().NotBeSameAs(level1);
            gotDoc.ToDictionary().ShouldBeEquivalentTo(dict);
        }