コード例 #1
0
        public void TestHashtableSerializedAsArrayOfArrays()
        {
            var d = new D2 {
                H = new Hashtable {
                    { "x", 1 }
                }
            };
            var json     = d.ToJson();
            var expected = "{ 'H' : [['x', 1]] }".Replace("'", "\"");

            Assert.AreEqual(expected, json);

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

            Assert.AreEqual(1, r.H.Count);
            Assert.AreEqual(1, r.H["x"]);
        }
コード例 #2
0
        public void TestHashtableSerializedAsArrayOfArrays()
        {
            var d = new D2 { H = new Hashtable { { "x", 1 } } };
            var json = d.ToJson();
            var expected = "{ 'H' : [['x', 1]] }".Replace("'", "\"");
            Assert.AreEqual(expected, json);

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