Пример #1
0
        public void T_01_Equals()
        {
            var row = 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
            };

            var rc = new RowConverter();

            var doc = rc.RowToBSONDocument(row, "A");

            Console.WriteLine(doc.ToString());

            var row2 = new RowA();

            rc.BSONDocumentToRow(doc, row2, "A");

            Assert.IsTrue(row.Equals(row2));
        }
Пример #2
0
    public void T_01_Equals()
    {
      var row = 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
      };
        
      var rc = new RowConverter();
      
      var doc = rc.RowToBSONDocument( row, "A" );

      Console.WriteLine(doc.ToString());

      var row2 = new RowA();
      rc.BSONDocumentToRow(doc, row2, "A");

      Assert.IsTrue( row.Equals( row2 ) );
    }
Пример #3
0
        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), 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,

                Byte2   = null,
                SByte2  = null,
                Short2  = null,
                UShort2 = null,
                Int2    = null,
                Uint2   = null,
                Long2   = null,
                ULong2  = null
            };

            var rc = new RowConverter();

            var docOriginal = rc.RowToBSONDocument(row, "A");
            var doc         = fullCopy(docOriginal);

            Console.WriteLine(doc.ToString());

            Assert.IsTrue(BIN.SequenceEqual((byte[])doc["Bytes1"]));
            Assert.IsTrue(doc["Bytes2"] is global::MongoDB.Bson.BsonNull);

            var row2 = new RowA();

            rc.BSONDocumentToRow(doc, row2, "A");

            Assert.IsTrue(row.Equals(row2));
            Assert.IsTrue(BIN.SequenceEqual(row2.Bytes1));
            Assert.IsNull(row2.Bytes2);
            Assert.IsFalse(object.ReferenceEquals(BIN, row2.Bytes1));
        }
Пример #4
0
        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), 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,

            Byte2 = null,
            SByte2 = null,
            Short2 = null,
            UShort2 = null,
            Int2 = null,
            Uint2 = null,
            Long2 = null,
            ULong2 = null
              };

              var rc = new RowConverter();

              var docOriginal = rc.RowToBSONDocument( row, "A" );
              var doc = fullCopy( docOriginal );

              Console.WriteLine(doc.ToString());

              Assert.IsTrue( BIN.SequenceEqual( (byte[])doc["Bytes1"] ));
              Assert.IsTrue( doc["Bytes2"] is global::MongoDB.Bson.BsonNull);

              var row2 = new RowA();
              rc.BSONDocumentToRow(doc, row2, "A");

              Assert.IsTrue( row.Equals( row2 ) );
              Assert.IsTrue( BIN.SequenceEqual( row2.Bytes1 ));
              Assert.IsNull( row2.Bytes2 );
              Assert.IsFalse( object.ReferenceEquals(BIN, row2.Bytes1) );
        }
Пример #5
0
        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), 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
            };

            var rc = new RowConverter();

            var docOriginal = rc.RowToBSONDocument(row, "A");

            var doc = fullCopy(docOriginal);

            Console.WriteLine(doc.ToString());

            var row2 = new RowA();

            rc.BSONDocumentToRow(doc, row2, "A");

            Assert.AreEqual("Mudaker", row2.String1);
            Assert.IsNull(row2.String2);
            Assert.IsTrue(row2.Bool1);
            Assert.IsNull(row2.Bool2);
            Assert.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1);
            Assert.IsNull(row2.Guid2);
            Assert.AreEqual(new GDID(0, 12345), row2.Gdid1);
            Assert.IsNull(row2.Gdid2);
            Assert.AreEqual(127.0123f, row2.Float1);
            Assert.IsNull(row2.Float2);
            Assert.AreEqual(122345.012d, row2.Double1);
            Assert.IsNull(row2.Double2);
            Assert.AreEqual(1234567.098M, row2.Decimal1);
            Assert.IsNull(row2.Decimal2);
            Assert.AreEqual(new Amount("din", 123.11M), row2.Amount1);
            Assert.IsNull(row2.Amount2);
            Assert.NotNull(row2.Bytes1);
            Assert.IsTrue(BYTES1.SequenceEqual(row2.Bytes1));
            Assert.IsNull(row2.Bytes2);
        }
Пример #6
0
        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), Date2 = new DateTime(1680, 12, 11),
                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
            };

            var rc = new RowConverter();

            var doc = rc.RowToBSONDocument(row, "A");

            Console.WriteLine(doc.ToString());

            var row2 = new RowA();

            rc.BSONDocumentToRow(doc, row2, "A");

            Assert.AreEqual("Mudaker", row2.String1);
            Assert.AreEqual("Kapernik", row2.String2);
            Assert.IsFalse(row2.Bool1);
            Assert.IsTrue(row2.Bool2.Value);
            Assert.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1);
            Assert.AreEqual(new Guid("{BABACACA-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid2);
            Assert.AreEqual(new GDID(3, 12345), row2.Gdid1);
            Assert.AreEqual(new GDID(4, 1212345), row2.Gdid2);
            Assert.AreEqual(127.0123f, row2.Float1);
            Assert.AreEqual(-0.123f, row2.Float2);
            Assert.AreEqual(122345.012d, row2.Double1);
            Assert.AreEqual(-12345.11f, row2.Double2);
            Assert.AreEqual(1234567.098M, row2.Decimal1);
            Assert.AreEqual(22m, row2.Decimal2);
            Assert.AreEqual(new Amount("din", 123.11M), row2.Amount1);
            Assert.AreEqual(new Amount("din", 8901234567890.012M), row2.Amount2);
            Assert.IsTrue(BYTES1.SequenceEqual(row2.Bytes1));
            Assert.IsTrue(BYTES2.SequenceEqual(row2.Bytes2));
        }
Пример #7
0
        public void T_04_Targeting()
        {
            var row = new RowA
            {
                String1 = "Mudaker", String2 = "Someone",
            };

            var rc = new RowConverter();

            var doc = rc.RowToBSONDocument(row, "A");

            Console.WriteLine(doc.ToString());
            Assert.AreEqual("Someone", doc["s2"].ToString());

            doc = rc.RowToBSONDocument(row, "B");
            Console.WriteLine(doc.ToString());
            Assert.AreEqual("Someone", doc["STRING-2"].ToString());


            doc = rc.RowToBSONDocument(row, "NonExistent");
            Console.WriteLine(doc.ToString());
            Assert.AreEqual("Someone", doc["String2"].ToString());
        }
Пример #8
0
        public void T_04_Targeting()
        {
            var row = new RowA
              {
            String1 = "Mudaker", String2 = "Someone",
              };

              var rc = new RowConverter();

              var doc = rc.RowToBSONDocument( row, "A" );
              Console.WriteLine(doc.ToString());
              Assert.AreEqual( "Someone", doc["s2"].ToString());

              doc = rc.RowToBSONDocument( row, "B" );
              Console.WriteLine(doc.ToString());
              Assert.AreEqual( "Someone", doc["STRING-2"].ToString());

              doc = rc.RowToBSONDocument( row, "NonExistent" );
              Console.WriteLine(doc.ToString());
              Assert.AreEqual( "Someone", doc["String2"].ToString());
        }
Пример #9
0
        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), Date2 = new DateTime(1680, 12, 11),
            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
              };

              var rc = new RowConverter();

              var doc = rc.RowToBSONDocument( row, "A" );

              Console.WriteLine(doc.ToString());

              var row2 = new RowA();
              rc.BSONDocumentToRow(doc, row2, "A");

              Assert.AreEqual("Mudaker", row2.String1);
              Assert.AreEqual("Kapernik", row2.String2);
              Assert.IsFalse( row2.Bool1 );
              Assert.IsTrue( row2.Bool2.Value );
              Assert.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1);
              Assert.AreEqual(new Guid("{BABACACA-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid2);
              Assert.AreEqual(new GDID(3, 12345), row2.Gdid1);
              Assert.AreEqual(new GDID(4, 1212345), row2.Gdid2);
              Assert.AreEqual(127.0123f, row2.Float1);
              Assert.AreEqual(-0.123f, row2.Float2);
              Assert.AreEqual(122345.012d, row2.Double1);
              Assert.AreEqual(-12345.11f, row2.Double2);
              Assert.AreEqual(1234567.098M, row2.Decimal1);
              Assert.AreEqual(22m, row2.Decimal2);
              Assert.AreEqual(new Amount("din", 123.11M), row2.Amount1);
              Assert.AreEqual(new Amount("din", 8901234567890.012M), row2.Amount2);
              Assert.IsTrue(BYTES1.SequenceEqual(row2.Bytes1));
              Assert.IsTrue(BYTES2.SequenceEqual(row2.Bytes2));
        }
Пример #10
0
        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), 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
              };

              var rc = new RowConverter();

              var docOriginal = rc.RowToBSONDocument( row, "A" );

              var doc = fullCopy( docOriginal );

              Console.WriteLine(doc.ToString());

              var row2 = new RowA();
              rc.BSONDocumentToRow(doc, row2, "A");

              Assert.AreEqual("Mudaker", row2.String1);
              Assert.IsNull( row2.String2);
              Assert.IsTrue( row2.Bool1 );
              Assert.IsNull( row2.Bool2);
              Assert.AreEqual(new Guid("{9195F7DB-FE21-4BB2-B006-2496F4E24D14}"), row2.Guid1);
              Assert.IsNull( row2.Guid2);
              Assert.AreEqual(new GDID(0, 12345), row2.Gdid1);
              Assert.IsNull( row2.Gdid2);
              Assert.AreEqual(127.0123f, row2.Float1);
              Assert.IsNull( row2.Float2);
              Assert.AreEqual(122345.012d, row2.Double1);
              Assert.IsNull( row2.Double2);
              Assert.AreEqual(1234567.098M, row2.Decimal1);
              Assert.IsNull( row2.Decimal2);
              Assert.AreEqual(new Amount("din", 123.11M), row2.Amount1);
              Assert.IsNull( row2.Amount2);
              Assert.NotNull( row2.Bytes1);
              Assert.IsTrue( BYTES1.SequenceEqual( row2.Bytes1) );
              Assert.IsNull( row2.Bytes2);
        }