Ejemplo n.º 1
0
        public void TestReadEmptyDocument()
        {
            byte[] buf = HexToBytes("0500000000");
            MemoryStream ms = new MemoryStream(buf);
            BsonReader reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();

            Assert.IsNotNull(doc);
        }
Ejemplo n.º 2
0
        public void TestReadEmptyDocument()
        {
            byte[]       buf    = HexToBytes("0500000000");
            MemoryStream ms     = new MemoryStream(buf);
            BsonReader   reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();

            Assert.IsNotNull(doc);
        }
Ejemplo n.º 3
0
        public void TestReadDocWithDocs()
        {
            //            Document doc = new Document().Append("a", new Document().Append("b", new Document().Append("c",new Document())));
            //            Console.WriteLine(ConvertDocToHex(doc));
            byte[] buf = HexToBytes("1D000000036100150000000362000D0000000363000500000000000000");
            MemoryStream ms = new MemoryStream(buf);
            BsonReader reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();
            Assert.IsNotNull(doc, "Document was null");
            Assert.AreEqual(buf.Length, reader.Position);
            Assert.IsTrue(doc.Contains("a"));
        }
Ejemplo n.º 4
0
        public void TestReadDocWithDocs()
        {
//            Document doc = new Document().Append("a", new Document().Append("b", new Document().Append("c",new Document())));
//            Console.WriteLine(ConvertDocToHex(doc));
            byte[]       buf    = HexToBytes("1D000000036100150000000362000D0000000363000500000000000000");
            MemoryStream ms     = new MemoryStream(buf);
            BsonReader   reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();

            Assert.IsNotNull(doc, "Document was null");
            Assert.AreEqual(buf.Length, reader.Position);
            Assert.IsTrue(doc.Contains("a"));
        }
Ejemplo n.º 5
0
        public void TestReadMultiElementDocument()
        {
            byte[]       buf    = HexToBytes("2D000000075F6964004A753AD8FAC16EA58B290351016100000000000000F03F02620005000000746573740000");
            MemoryStream ms     = new MemoryStream(buf);
            BsonReader   reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();

            Assert.IsNotNull(doc, "Document was null");
            Assert.IsTrue(doc.Contains("_id"));
            Assert.IsTrue(doc.Contains("a"));
            Assert.IsTrue(doc.Contains("b"));
            Assert.AreEqual("\"4a753ad8fac16ea58b290351\"", ((Oid)doc["_id"]).ToString());
            Assert.AreEqual(1, Convert.ToInt32(doc["a"]));
            Assert.AreEqual("test", (String)doc["b"]);
        }
Ejemplo n.º 6
0
        public void TestReadMultiElementDocument()
        {
            byte[] buf = HexToBytes("2D000000075F6964004A753AD8FAC16EA58B290351016100000000000000F03F02620005000000746573740000");
            MemoryStream ms = new MemoryStream(buf);
            BsonReader reader = new BsonReader(ms);

            Document doc = reader.ReadDocument();

            Assert.IsNotNull(doc, "Document was null");
            Assert.IsTrue(doc.Contains("_id"));
            Assert.IsTrue(doc.Contains("a"));
            Assert.IsTrue(doc.Contains("b"));
            Assert.AreEqual("\"4a753ad8fac16ea58b290351\"", ((Oid)doc["_id"]).ToString());
            Assert.AreEqual(1, Convert.ToInt32(doc["a"]));
            Assert.AreEqual("test", (String)doc["b"]);
        }