コード例 #1
0
        public void TestDoc() {
            var table = new Hashtable();
            table["Text"] = "hello";
            table["Enum"] = E.B;
            var doc = new Doc { Values = table };

            var json = doc.ToJson();
            var expected = "{ 'Values' : { 'Text' : 'hello', 'Enum' : 1 } }".Replace("'", "\"");
            Assert.AreEqual(expected, json);
        }
コード例 #2
0
        public void TestDoc()
        {
            var table = new Hashtable();

            table["Text"] = "hello";
            table["Enum"] = E.B;
            var doc = new Doc {
                Values = table
            };

            var json     = doc.ToJson();
            var expected = "{ 'Values' : { 'Text' : 'hello', 'Enum' : 1 } }".Replace("'", "\"");

            Assert.AreEqual(expected, json);
        }
コード例 #3
0
        public void TestDoc()
        {
            var table = new Hashtable();
            table["Text"] = "hello";
            table["Enum"] = E.B;
            var doc = new Doc { Values = table };

            var json = doc.ToJson();
            // var expected = "{ 'Values' : { 'Text' : 'hello', 'Enum' : 1 } }".Replace("'", "\"");
            // Assert.AreEqual(expected, json);
            var rehydrated = BsonSerializer.Deserialize<Doc>(json);
            Assert.IsNotNull(rehydrated.Values);
            Assert.AreEqual(doc.Values.Count, rehydrated.Values.Count);
            Assert.AreEqual(doc.Values["Text"], rehydrated.Values["Text"]);
            Assert.AreEqual((int)doc.Values["Enum"], rehydrated.Values["Enum"]);
        }
コード例 #4
0
        public void TestDoc()
        {
            var table = new Hashtable();

            table["Text"] = "hello";
            table["Enum"] = E.B;
            var doc = new Doc {
                Values = table
            };

            var json = doc.ToJson();
            // var expected = "{ 'Values' : { 'Text' : 'hello', 'Enum' : 1 } }".Replace("'", "\"");
            // Assert.AreEqual(expected, json);
            var rehydrated = BsonSerializer.Deserialize <Doc>(json);

            Assert.IsNotNull(rehydrated.Values);
            Assert.AreEqual(doc.Values.Count, rehydrated.Values.Count);
            Assert.AreEqual(doc.Values["Text"], rehydrated.Values["Text"]);
            Assert.AreEqual((int)doc.Values["Enum"], rehydrated.Values["Enum"]);
        }