Пример #1
0
        public void TestDictionarySerializedAsBsonArray()
        {
            var c = new C4 {
                D = new Dictionary <string, object> {
                    { "x", 1 }
                }
            };
            var json     = c.ToJson();
            var expected = "{ 'D' : [['x', 1]] }".Replace("'", "\"");

            Assert.Equal(expected, json);

            var r = BsonSerializer.Deserialize <C4>(json);

            Assert.Equal(1, r.D.Count);
            Assert.Equal(1, r.D["x"]);
        }
        public void TestDictionarySerializedAsBsonArray()
        {
            var c = new C4 { D = new Dictionary<string, object> { { "x", 1 } } };
            var json = c.ToJson();
            var expected = "{ 'D' : [['x', 1]] }".Replace("'", "\"");
            Assert.AreEqual(expected, json);

            var r = BsonSerializer.Deserialize<C4>(json);
            Assert.AreEqual(1, r.D.Count);
            Assert.AreEqual(1, r.D["x"]);
        }