public void TestHashtableDynamicRepresentationWithDot() { var d = new HX { Id = 1, Data = new Hashtable { { "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 TestHashtableDynamicRepresentationWithDot() { var d = new HX { Id = 1, Data = new Hashtable { { "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 TestHashtableDynamicRepresentationWithDot() { var d = new HX { Id = 1, Data = new Hashtable { { "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 TestHashtableDynamicRepresentationNormal() { var d = new HX { Id = 1, Data = new Hashtable { { "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"]); }