public void TestGenericDictionaryDynamicRepresentationWithDot()
        {
            var d = new GDX {
                Id = 1, Data = new Dictionary <string, int> {
                    { "a.b", 1 }
                }
            };
            var expected = "{ '_id' : 1, 'Data' : { 'a.b' : 1 } }".Replace("'", "\"");
            var json     = d.ToJson();

            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            Assert.Throws <BsonSerializationException>(() => _collection.Insert(d));
        }
Example #2
0
        public void TestGenericDictionaryDynamicRepresentationWithDot()
        {
            var d = new GDX {
                Id = 1, Data = new Dictionary <string, int> {
                    { "a.b", 1 }
                }
            };
            var expected = "{ '_id' : 1, 'Data' : [['a.b', 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.b"]);
        }
        public void TestGenericDictionaryDynamicRepresentationWithDot()
        {
            var d = new GDX { Id = 1, Data = new Dictionary<string, int> { { "a.b", 1 } } };
            var expected = "{ '_id' : 1, 'Data' : [['a.b', 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.b"]);
        }
Example #4
0
        public void TestGenericDictionaryDynamicRepresentationWithDot()
        {
            var d = new GDX { Id = 1, Data = new Dictionary<string, int> { { "a.b", 1 } } };
            var expected = "{ '_id' : 1, 'Data' : { 'a.b' : 1 } }".Replace("'", "\"");
            var json = d.ToJson();
            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            Assert.Throws<BsonSerializationException>(() => _collection.Insert(d));
        }
        public void TestGenericDictionaryDynamicRepresentationNormal()
        {
            var d = new GDX { Id = 1, Data = new Dictionary<string, int> { { "abc", 1 } } };
            var expected = "{ '_id' : 1, 'Data' : { 'abc' : 1 } }".Replace("'", "\"");
            var json = d.ToJson();
            Assert.AreEqual(expected, json);

            _collection.RemoveAll();
            _collection.Insert(d);
            var r = _collection.FindOne(Query.EQ(BsonDocument.ID_FIELD, d.Id));
            Assert.AreEqual(d.Id, r.Id);
            Assert.AreEqual(1, r.Data.Count);
            Assert.AreEqual(1, r.Data["abc"]);
        }