public void TestGenericDictionaryArrayRepresentationWithDollar() {
            var d = new GDA { Id = 1, Data = new Dictionary<string, int> { { "$a", 1 } } };
            var expected = "{ '_id' : 1, 'Data' : [['$a', 1]] }".Replace("'", "\"");
            var json = d.ToJson();
            Assert.AreEqual(expected, json);

            collection.RemoveAll();
            collection.Insert(d);
            var r = collection.FindOne(Query.EQ("_id", d.Id));
            Assert.AreEqual(d.Id, r.Id);
            Assert.AreEqual(1, r.Data.Count);
            Assert.AreEqual(1, r.Data["$a"]);
        }
Exemple #2
0
        public void TestGenericDictionaryArrayRepresentationWithDollar()
        {
            var d = new GDA {
                Id = 1, Data = new Dictionary <string, int> {
                    { "$a", 1 }
                }
            };
            var expected = "{ '_id' : 1, 'Data' : [['$a', 1]] }".Replace("'", "\"");
            var json     = d.ToJson();

            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            _collection.Insert(d);
            var r = _collection.FindOne(Query.EQ("_id", d.Id));

            Assert.AreEqual(d.Id, r.Id);
            Assert.AreEqual(1, r.Data.Count);
            Assert.AreEqual(1, r.Data["$a"]);
        }