Esempio n. 1
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, 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 RowConverter();

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

            Console.WriteLine(doc.ToString());

            Assert.IsTrue(BIN.SequenceEqual(((BSONBinaryElement)doc["Bytes1"]).Value.Data));
            //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));
        }
Esempio n. 2
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, 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 RowConverter();

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

        Console.WriteLine(doc.ToString());

        Assert.IsTrue(BIN.SequenceEqual( ((BSONBinaryElement)doc["Bytes1"]).Value.Data ));
        //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));
      }