public void T_17_VersionChange_AmorphousExtra() { var BYTES = new byte[] { 0x00, 0x79, 0x14 }; var rowA = new RowVersionA { FirstName = "Vladimir", LastName = "Lenin", Age = DateTime.Now.Year - 1870 }; rowA.AmorphousData["AABB"] = "extra data"; rowA.AmorphousData["Bytes"] = BYTES; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(rowA, "A", useAmorphousData: true); Console.WriteLine(doc.ToString()); var rowB = new RowVersionB(); rc.BSONDocumentToDataDoc(doc, rowB, "MyLegacySystem", useAmorphousData: true); Aver.AreEqual("Vladimir", rowB.FirstName); Aver.AreEqual("Lenin", rowB.LastName); Aver.AreEqual(1870, rowB.DOB.Year); Aver.AreObjectsEqual("extra data", rowB.AmorphousData["AABB"]); Aver.IsTrue(BYTES.SequenceEqual((byte[])rowB.AmorphousData["Bytes"])); }
public void T_Null() { var rowA = new RowWithNulls { FirstName = "Vladimir", LastName = null, Age = 240, G_GDID = null }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(rowA, "A"); Console.WriteLine(doc["LastName"]); Console.WriteLine(doc["G_GDID"]); Console.WriteLine(doc.ToString()); var row2 = new RowWithNulls(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreEqual("Vladimir", row2.FirstName); Aver.IsNull(row2.LastName); Aver.AreEqual(240, row2.Age); Aver.IsNull(row2.G_GDID); }
public void InferSchema() { var doc = new BSONDocument(); doc.Set(new BSONStringElement("FullName", "Alex Bobby")); doc.Set(new BSONInt32Element("Age", 123)); doc.Set(new BSONBooleanElement("IsGood", true)); var c = new DataDocConverter(); var schema = c.InferSchemaFromBSONDocument(doc); Aver.AreEqual(3, schema.FieldCount); Aver.AreEqual(0, schema["FullName"].Order); Aver.AreEqual(1, schema["Age"].Order); Aver.AreEqual(2, schema["IsGood"].Order); Aver.AreObjectsEqual(typeof(object), schema["FullName"].NonNullableType); Aver.AreObjectsEqual(typeof(object), schema["Age"].NonNullableType); Aver.AreObjectsEqual(typeof(object), schema["IsGood"].NonNullableType); var row = new DynamicDoc(schema); c.BSONDocumentToDataDoc(doc, row, null); Aver.AreObjectsEqual("Alex Bobby", row[0]); Aver.AreObjectsEqual(123, row[1]); Aver.AreObjectsEqual(true, row[2]); Aver.AreObjectsEqual("Alex Bobby", row["FullName"]); Aver.AreObjectsEqual(123, row["Age"]); Aver.AreObjectsEqual(true, row["IsGood"]); }
public void T_02_Manual() { var BYTES1 = new byte[] { 0x00, 0x79, 0x14 }; var row = new RowA { String1 = "Mudaker", String2 = null, Date1 = new DateTime(1980, 07, 12, 10, 10, 10, DateTimeKind.Utc), Date2 = null, Bool1 = true, Bool2 = null, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12345), Gdid2 = null, Float1 = 127.0123f, Float2 = null, Double1 = 122345.012d, Double2 = null, Decimal1 = 1234567.098M, Decimal2 = null, Amount1 = new Amount("din", 123.11M), Amount2 = null, Bytes1 = BYTES1, Bytes2 = null, ETest1 = 0, EFlags1 = 0, ETest2 = null, EFlags2 = null }; var rc = new DataDocConverter(); var docOriginal = rc.DataDocToBSONDocument(row, "A"); var doc = fullCopy(docOriginal); Console.WriteLine(doc.ToString()); var row2 = new RowA(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreEqual("Mudaker", row2.String1); Aver.IsNull(row2.String2); Aver.IsTrue(row2.Bool1); Aver.IsNull(row2.Bool2); Aver.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1); Aver.IsNull(row2.Guid2); Aver.AreEqual(new GDID(0, 12345), row2.Gdid1); Aver.IsNull(row2.Gdid2); Aver.AreEqual(127.0123f, row2.Float1); Aver.IsNull(row2.Float2); Aver.AreEqual(122345.012d, row2.Double1); Aver.IsNull(row2.Double2); Aver.AreEqual(1234567.098M, row2.Decimal1); Aver.IsNull(row2.Decimal2); Aver.AreEqual(new Amount("din", 123.11M), row2.Amount1); Aver.IsNull(row2.Amount2); Aver.IsNotNull(row2.Bytes1); Aver.IsTrue(BYTES1.SequenceEqual(row2.Bytes1)); Aver.IsNull(row2.Bytes2); Aver.AreEqual(0, (int)row2.ETest1); Aver.AreEqual(0, (int)row2.EFlags1); Aver.IsNull(row2.ETest2); Aver.IsNull(row2.EFlags2); }
public void T_03_Manual_wo_NULLs() { var BYTES1 = new byte[] {}; var BYTES2 = new byte[] { 0x00, 0x79, 0x14 }; var row = new RowA { String1 = "Mudaker", String2 = "Kapernik", Date1 = new DateTime(1980, 07, 12, 1, 2, 3, DateTimeKind.Utc), Date2 = new DateTime(1680, 12, 11, 5, 6, 7, DateTimeKind.Utc), Bool1 = false, Bool2 = true, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = new Guid("{BABACACA-FE21-4BB2-B006-2496F4E24D14}"), Gdid1 = new GDID(3, 12345), Gdid2 = new GDID(4, 1212345), Float1 = 127.0123f, Float2 = -0.123f, Double1 = 122345.012d, Double2 = -12345.11f, Decimal1 = 1234567.098M, Decimal2 = 22m, Amount1 = new Amount("din", 123.11M), Amount2 = new Amount("din", 8901234567890.012M), Bytes1 = BYTES1, Bytes2 = BYTES2, ETest1 = ETest.One, EFlags1 = EFlags.First, ETest2 = ETest.Two, EFlags2 = EFlags.Second | EFlags.Third }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Console.WriteLine(doc.ToString()); var row2 = new RowA(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreEqual("Mudaker", row2.String1); Aver.AreEqual("Kapernik", row2.String2); Aver.IsFalse(row2.Bool1); Aver.IsTrue(row2.Bool2.Value); Aver.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1); Aver.AreEqual(new Guid("{BABACACA-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid2); Aver.AreEqual(new GDID(3, 12345), row2.Gdid1); Aver.AreEqual(new GDID(4, 1212345), row2.Gdid2); Aver.AreEqual(127.0123f, row2.Float1); Aver.AreEqual(-0.123f, row2.Float2); Aver.AreEqual(122345.012d, row2.Double1); Aver.AreEqual(-12345.11f, row2.Double2); Aver.AreEqual(1234567.098M, row2.Decimal1); Aver.AreEqual(22m, row2.Decimal2); Aver.AreEqual(new Amount("din", 123.11M), row2.Amount1); Aver.AreEqual(new Amount("din", 8901234567890.012M), row2.Amount2); Aver.IsTrue(BYTES1.SequenceEqual(row2.Bytes1)); Aver.IsTrue(BYTES2.SequenceEqual(row2.Bytes2)); Aver.IsTrue(ETest.One == row2.ETest1); Aver.IsTrue(EFlags.First == row2.EFlags1); Aver.IsTrue(ETest.Two == row2.ETest2); Aver.IsTrue((EFlags.Second | EFlags.Third) == row2.EFlags2); }
public void T_04_Array() { using (var client = new MongoClient(NOPApplication.Instance, "My Test")) { var db = client.DefaultLocalServer["db1"]; db["t1"].Drop(); var t1 = db["t1"]; var row = new ArrayRow { _id = 1, Map = new JSONDataMap { { "Name", "Xerson" }, { "Age", 123 } }, List = new List <object> { 1, true, "YEZ!", -123.01 }, ObjectArray = new object[] { 123, -12, 789d, null, new object[] { 54.67d, "alpIna" } }, MapArray = new JSONDataMap[] { new JSONDataMap { { "a", 1 }, { "b", true } }, new JSONDataMap { { "kosmos", 234.12 }, { "b", null } } }, MapList = new List <JSONDataMap> { new JSONDataMap { { "abc", 0 }, { "buba", -40.0789 } }, new JSONDataMap { { "nothing", null } } } }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Aver.AreEqual(1, t1.Insert(doc).TotalDocumentsAffected); var got = db["t1"].FindOne(Query.ID_EQ_Int32(1)); Aver.IsNotNull(got); var row1 = new ArrayRow(); rc.BSONDocumentToDataDoc(got, row1, "A"); Aver.AreObjectsEqual(row, row1); } }
public void T_05_WithInnerRows() { var BYTES = new byte[] { 0x00, 0x79, 0x14 }; var row = new RowB { Row1 = new RowA { String1 = "Mudaker", String2 = null, Date1 = new DateTime(1980, 07, 12), Date2 = null, Bool1 = true, Bool2 = null, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12345), Gdid2 = null, Float1 = 127.0123f, Float2 = null, Double1 = 122345.012d, Double2 = null, Decimal1 = 1234567.098M, Decimal2 = null, Amount1 = new Amount("din", 123.11M), Amount2 = null, Bytes1 = BYTES, Bytes2 = null }, Row2 = new RowA { String1 = "Abraham ILyach Lincoln", String2 = "I know that I know nothing", Date1 = new DateTime(1877, 01, 02), Date2 = new DateTime(1977, 03, 15), Bool1 = false, Bool2 = true, Guid1 = new Guid("{AAAAAAAA-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12323423423), Gdid2 = new GDID(0, 187760098292476423), Float1 = 127.0123f, Float2 = 123.2f, Double1 = 122345.012d, Double2 = -18293f, Decimal1 = 1234567.098M, Decimal2 = -2312m, Amount1 = new Amount("usd", 89123M), Amount2 = new Amount("usd", 12398933.123m), Bytes1 = null, Bytes2 = BYTES } }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Console.WriteLine(doc.ToString()); var row2 = new RowB(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.IsTrue(row.Equals(row2)); }
public void T_03_Update() { var BIN = new byte[] { 0x00, 0x79, 0x14 }; using (var client = new MongoClient(NOPApplication.Instance, "My Test")) { var db = client.DefaultLocalServer["db1"]; db["t1"].Drop(); var t1 = db["t1"]; var row = new TestRow() { _id = 1, String1 = "Mudaker", }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Aver.AreEqual(1, t1.Insert(doc).TotalDocumentsAffected); var updateResult = t1.Update ( new UpdateEntry ( Query.ID_EQ_Int32(1), new Update("{'String1': '$$VAL'}", true, new TemplateArg("VAL", BSONElementType.String, "makaka")), false, false ) ); var got = db["t1"].FindOne(Query.ID_EQ_Int32(1)); Aver.IsNotNull(got); var row1 = new TestRow(); rc.BSONDocumentToDataDoc(got, row1, "A"); Aver.AreEqual("makaka", row1.String1); } }
public void T_16_VersionChange_AmorphousDisabled_WithFilter() { var rowA = new RowVersionA { FirstName = "Vladimir", LastName = "Lenin", Age = DateTime.Now.Year - 1870 }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(rowA, "A", useAmorphousData: false); Console.WriteLine(doc.ToString()); var rowB = new RowVersionB(); rc.BSONDocumentToDataDoc(doc, rowB, "MyLegacySystem", useAmorphousData: false, filter: (d, e) => e.Name != "LastName"); Aver.AreEqual("Vladimir", rowB.FirstName); Aver.IsNull(rowB.LastName); Aver.AreEqual(new DateTime(), rowB.DOB); }
public void T_10_RowCycle_NoCycle() { var root = new RowCycle(); root.SomeInt = 1234; root.InnerRow = new RowCycle(); root.InnerRow.SomeInt = 567; root.InnerRow.InnerRow = null; //NO CYCLE!!!! var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(root, "A"); Console.WriteLine(doc.ToString()); var root2 = new RowCycle(); rc.BSONDocumentToDataDoc(doc, root2, "A"); Aver.AreEqual(1234, root2.SomeInt); Aver.IsNotNull(root2.InnerRow); Aver.AreEqual(567, root2.InnerRow.SomeInt); }
public void T_08_VersionChange() { var rowA = new RowVersionA { FirstName = "Vladimir", LastName = "Lenin", Age = DateTime.Now.Year - 1870 }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(rowA, "A"); Console.WriteLine(doc.ToString()); var rowB = new RowVersionB(); rc.BSONDocumentToDataDoc(doc, rowB, "MyLegacySystem"); Aver.AreEqual("Vladimir", rowB.FirstName); Aver.AreEqual("Lenin", rowB.LastName); Aver.AreEqual(1870, rowB.DOB.Year); }
public void T_16_VersionChange_AmorphousDisabled() { var rowA = new RowVersionA { FirstName = "Vladimir", LastName = "Lenin", Age = DateTime.Now.Year - 1870 }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(rowA, "A", useAmorphousData: false); doc.ToString().See(); var rowB = new RowVersionB(); rc.BSONDocumentToDataDoc(doc, rowB, "MyLegacySystem", useAmorphousData: false); Aver.AreEqual("Vladimir", rowB.FirstName); Aver.AreEqual("Lenin", rowB.LastName); Aver.AreEqual(new DateTime(), rowB.DOB); }
public void T_00_Enum_Equals() { var row1 = new EnumRow { ETest1 = ETest.One, EFlags1 = EFlags.FirstSecond }; var rc = new DataDocConverter(); var docOriginal = rc.DataDocToBSONDocument(row1, "A"); var doc = fullCopy(docOriginal); Console.WriteLine(doc.ToString()); var row2 = new EnumRow(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreObjectsEqual(row1, row2); Aver.IsTrue(ETest.One == row2.ETest1); Aver.IsTrue(EFlags.FirstSecond == row2.EFlags1); }
public void T_09_DynamicRow() { var BYTES = new byte[] { 0x00, 0x79, 0x14 }; var schema = new Schema("Dynamic Schema", new Schema.FieldDef("ID", typeof(int), new List <FieldAttribute> { new FieldAttribute(required: true, key: true) }), new Schema.FieldDef("Description", typeof(string), new List <FieldAttribute> { new FieldAttribute(required: true) }), new Schema.FieldDef("Bytes", typeof(byte[]), new List <FieldAttribute> { new FieldAttribute(required: true) }) ); var row = new DynamicDoc(schema); row["ID"] = 123; row["Description"] = "T-90 Tank"; row["Bytes"] = BYTES; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Console.WriteLine(doc.ToString()); var row2 = new DynamicDoc(schema); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreObjectsEqual(123, row2["ID"]); Aver.AreObjectsEqual("T-90 Tank", row2["Description"]); Aver.IsTrue(BYTES.SequenceEqual((byte[])row2["Bytes"])); }
public void T_01_Insert() { var BIN = new byte[] { 0x00, 0x79, 0x14 }; using (var client = new MongoClient(NOPApplication.Instance, "My Test")) { var db = client.DefaultLocalServer["db1"]; db["t1"].Drop(); var t1 = db["t1"]; var row = new TestRow() { _id = 1, String1 = "Mudaker", String2 = null, Date1 = new DateTime(1980, 07, 12, 10, 13, 27, DateTimeKind.Utc), Date2 = null, Bool1 = true, Bool2 = null, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12345), Gdid2 = null, Float1 = 127.0123f, Float2 = null, Double1 = 122345.012d, Double2 = null, Decimal1 = 1234567.098M, Decimal2 = null, Amount1 = new Amount("din", 123.11M), Amount2 = null, Bytes1 = BIN, Bytes2 = null, Byte1 = 23, SByte1 = -3, Short1 = -32761, UShort1 = 65535, Int1 = 4324, Uint1 = 42345, Long1 = 993, ULong1 = 8829383762, ETest1 = ETest.Two, EFlags1 = EFlags.First | EFlags.Third, Byte2 = null, SByte2 = null, Short2 = null, UShort2 = null, Int2 = null, Uint2 = null, Long2 = null, ULong2 = null, ETest2 = null, EFlags2 = null }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Aver.AreEqual(1, t1.Insert(doc).TotalDocumentsAffected); var got = db["t1"].FindOne(Query.ID_EQ_Int32(1)); Aver.IsNotNull(got); var row1 = new TestRow(); rc.BSONDocumentToDataDoc(got, row1, "A"); Aver.AreObjectsEqual(row, row1); } }
public void T_02_Update_Parallel() { const int CNT = 11973; var BIN = new byte[] { 0x00, 0x79, 0x14 }; using (var client = new MongoClient(NOPApplication.Instance, "My Test")) { var db = client.DefaultLocalServer["db1"]; db["t1"].Drop(); var t1 = db["t1"]; var rows = new TestRow[CNT]; var rc = new DataDocConverter(); var sw = new Stopwatch(); sw.Start(); Parallel.For(0, CNT, i => { var row = new TestRow() { _id = i, String1 = "Mudaker", String2 = null, Date1 = new DateTime(1980, 07, 12, 10, 13, 27, DateTimeKind.Utc), Date2 = null, Bool1 = true, Bool2 = null, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12345), Gdid2 = null, Float1 = 127.0123f, Float2 = null, Double1 = 122345.012d, Double2 = null, Decimal1 = 1234567.098M, Decimal2 = null, Amount1 = new Amount("din", 123.11M), Amount2 = null, Bytes1 = BIN, Bytes2 = null, Byte1 = 23, SByte1 = -3, Short1 = -32761, UShort1 = 65535, Int1 = 4324, Uint1 = 42345, Long1 = 993, ULong1 = 8829383762, ETest1 = ETest.Two, EFlags1 = EFlags.First | EFlags.Third, Byte2 = null, SByte2 = null, Short2 = null, UShort2 = null, Int2 = null, Uint2 = null, Long2 = null, ULong2 = null, ETest2 = null, EFlags2 = null }; rows[i] = row; var doc = rc.DataDocToBSONDocument(row, "A"); Aver.AreEqual(1, t1.Insert(doc).TotalDocumentsAffected); }); sw.Stop(); Console.WriteLine("{0:N0} row inserted in {1:N3} sec on {2:N0} ops/sec", CNT, sw.Elapsed.TotalSeconds, CNT / sw.Elapsed.TotalSeconds); sw.Restart(); Parallel.For(0, CNT, i => { var row = rows[i]; row.String1 = "makaka" + i.ToString(); row.Int1 = 9789 + (i * 100); var doc = rc.DataDocToBSONDocument(row, "A"); var r = t1.Save(doc); Aver.AreEqual(1, r.TotalDocumentsAffected); Aver.AreEqual(1, r.TotalDocumentsUpdatedAffected); Aver.IsNull(r.WriteErrors); }); sw.Stop(); Console.WriteLine("{0:N0} row updated in {1:N3} sec on {2:N0} ops/sec", CNT, sw.Elapsed.TotalSeconds, CNT / sw.Elapsed.TotalSeconds); sw.Restart(); var RCNT = CNT * 3; Parallel.For(0, RCNT, i => { var j = i % CNT; var got = db["t1"].FindOne(Query.ID_EQ_Int32(j)); Aver.IsNotNull(got); var row1 = new TestRow(); rc.BSONDocumentToDataDoc(got, row1, "A"); Aver.AreObjectsEqual(rows[j], row1); }); sw.Stop(); Console.WriteLine("{0:N0} row red in {1:N3} sec on {2:N0} ops/sec", RCNT, sw.Elapsed.TotalSeconds, RCNT / sw.Elapsed.TotalSeconds); } }
public void T_01_Equals() { var BIN = new byte[] { 0x00, 0x79, 0x14 }; var row = new RowA { String1 = "Mudaker", String2 = null, Date1 = new DateTime(1980, 07, 12, 10, 13, 27, DateTimeKind.Utc), Date2 = null, Bool1 = true, Bool2 = null, Guid1 = new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), Guid2 = null, Gdid1 = new GDID(0, 12345), Gdid2 = null, Float1 = 127.0123f, Float2 = null, Double1 = 122345.012d, Double2 = null, Decimal1 = 1234567.098M, Decimal2 = null, Amount1 = new Amount("din", 123.11M), Amount2 = null, Bytes1 = BIN, Bytes2 = null, Byte1 = 23, SByte1 = -3, Short1 = -32761, UShort1 = 65535, Int1 = 4324, Uint1 = 42345, Long1 = 993, ULong1 = 8829383762, ETest1 = ETest.Two, EFlags1 = EFlags.First | EFlags.Third, Byte2 = null, SByte2 = null, Short2 = null, UShort2 = null, Int2 = null, Uint2 = null, Long2 = null, ULong2 = null, ETest2 = null, EFlags2 = null }; var rc = new DataDocConverter(); var docOriginal = rc.DataDocToBSONDocument(row, "A"); var doc = fullCopy(docOriginal); Console.WriteLine(doc.ToString()); Aver.IsTrue(BIN.SequenceEqual(((BSONBinaryElement)doc["Bytes1"]).Value.Data)); //Aver.IsTrue(doc["Bytes2"] is global::MongoDB.Bson.BsonNull); var row2 = new RowA(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.IsTrue(row.Equals(row2)); Aver.IsTrue(BIN.SequenceEqual(row2.Bytes1)); Aver.IsNull(row2.Bytes2); Aver.IsFalse(object.ReferenceEquals(BIN, row2.Bytes1)); }
public void T_07_ArraysListsAndMaps() { var row = new RowC { Map = new JsonDataMap { { "Name", "Xerson" }, { "Age", 123 } }, List = new List <object> { 1, true, "YEZ!", -123.01m }, ObjectArray = new object[] { 123, -12, 789d, new GDID(0, 1223), null, new object[] { 54.67d, "alpIna" } }, MapArray = new JsonDataMap[] { new JsonDataMap { { "a", 1 }, { "b", true } }, new JsonDataMap { { "kosmos", 234.12 }, { "b", null } } }, MapList = new List <JsonDataMap> { new JsonDataMap { { "abc", 0 }, { "buba", new GDID(2, 1223) } }, new JsonDataMap { { "nothing", null } } } }; var rc = new DataDocConverter(); var doc = rc.DataDocToBSONDocument(row, "A"); Console.WriteLine(doc.ToString()); var row2 = new RowC(); rc.BSONDocumentToDataDoc(doc, row2, "A"); Aver.AreEqual(2, row2.Map.Count); Aver.AreObjectsEqual("Xerson", row2.Map["Name"]); Aver.AreObjectsEqual(123, row2.Map["Age"]); Aver.AreEqual(4, row2.List.Count); Aver.AreObjectsEqual(1, row2.List[0]); Aver.AreObjectsEqual(true, row2.List[1]); Aver.AreObjectsEqual("YEZ!", row2.List[2]); Aver.AreObjectsEqual((long)-123010m, row2.List[3]); //notice that "decimalness" is lost, because reading back into list<object> Aver.AreEqual(6, row2.ObjectArray.Length); Aver.AreObjectsEqual(123, row2.ObjectArray[0]); Aver.AreObjectsEqual(-12, row2.ObjectArray[1]); Aver.AreObjectsEqual(789d, row2.ObjectArray[2]); Aver.IsTrue((new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x04, 0xc7 }).SequenceEqual((byte[])(row2.ObjectArray[3])));//notice that GDID is lost, it got turned into int because reading back in object[], so no type conversion happens Aver.IsNull(row2.ObjectArray[4]); var arr = (object[])row2.ObjectArray[5]; Aver.IsNotNull(arr); Aver.AreObjectsEqual(54.67d, arr[0]); Aver.AreObjectsEqual("alpIna", arr[1]); Aver.AreEqual(2, row2.MapArray.Length); Aver.AreObjectsEqual(1, row2.MapArray[0]["a"]); Aver.AreObjectsEqual(true, row2.MapArray[0]["b"]); Aver.AreObjectsEqual(234.12, row2.MapArray[1]["kosmos"]); Aver.AreObjectsEqual(null, row2.MapArray[1]["b"]); Aver.AreEqual(2, row2.MapList.Count); Aver.AreEqual(2, row2.MapList[0].Count); Aver.AreObjectsEqual(0, row2.MapList[0]["abc"]); Aver.IsTrue((new byte[] { 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0x04, 0xc7 }).SequenceEqual((byte[])(row2.MapList[0]["buba"])));//"GDIDness" is lost Aver.AreEqual(1, row2.MapList[1].Count); Aver.IsNull(row2.MapList[1]["nothing"]); }