public void TestSerialize()
        {
            // Check under max record size
            DrawingGroupRecord r = new DrawingGroupRecord();
            byte[] rawData = new byte[100];
            rawData[0] = 100;
            rawData[99] = (byte)200;
            r.RawData = (rawData);
            byte[] buffer = new byte[r.RecordSize];
            int size = r.Serialize(0, buffer);
            Assert.AreEqual(104, size);
            Assert.AreEqual("[EB, 00, 64, 00, 64, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, C8]", HexDump.ToHex(buffer));

            // check at max record size
            rawData = new byte[MAX_DATA_SIZE];
            r.RawData = (rawData);
            buffer = new byte[r.RecordSize];
            size = r.Serialize(0, buffer);
            Assert.AreEqual(MAX_RECORD_SIZE, size);

            // check over max record size
            rawData = new byte[MAX_DATA_SIZE + 1];
            rawData[rawData.Length - 1] = (byte)255;
            r.RawData = (rawData);
            buffer = new byte[r.RecordSize];
            size = r.Serialize(0, buffer);
            Assert.AreEqual(MAX_RECORD_SIZE + 5, size);
            Assert.AreEqual("[EB, 00, 20, 20]", HexDump.ToHex(cut(buffer, 0, 4)));
            Assert.AreEqual("[00, EB, 00, 01, 00, FF]", HexDump.ToHex(cut(buffer, MAX_RECORD_SIZE - 1, MAX_RECORD_SIZE + 5)));

            // check continue record
            rawData = new byte[MAX_DATA_SIZE * 2 + 1];
            rawData[rawData.Length - 1] = (byte)255;
            r.RawData = (rawData);
            buffer = new byte[r.RecordSize];
            size = r.Serialize(0, buffer);
            Assert.AreEqual(MAX_RECORD_SIZE * 2 + 5, size);
            Assert.AreEqual(MAX_RECORD_SIZE * 2 + 5, r.RecordSize);
            Assert.AreEqual("[EB, 00, 20, 20]", HexDump.ToHex(cut(buffer, 0, 4)));
            Assert.AreEqual("[EB, 00, 20, 20]", HexDump.ToHex(cut(buffer, MAX_RECORD_SIZE, MAX_RECORD_SIZE + 4)));
            Assert.AreEqual("[3C, 00, 01, 00, FF]", HexDump.ToHex(cut(buffer, MAX_RECORD_SIZE * 2, MAX_RECORD_SIZE * 2 + 5)));

            // check continue record
            rawData = new byte[664532];
            r.RawData = (rawData);
            buffer = new byte[r.RecordSize];
            size = r.Serialize(0, buffer);
            Assert.AreEqual(664856, size);
            Assert.AreEqual(664856, r.RecordSize);
        }
        public void TestRecordSize()
        {
            DrawingGroupRecord r = new DrawingGroupRecord();
            Assert.AreEqual(4, r.RecordSize);

            EscherSpRecord sp = new EscherSpRecord();
            sp.RecordId = (EscherSpRecord.RECORD_ID);
            sp.Options = ((short)0x1111);
            sp.Flags = (-1);
            sp.ShapeId = (-1);
            EscherContainerRecord dggContainer = new EscherContainerRecord();
            dggContainer.Options = ((short)0x000F);
            dggContainer.RecordId = unchecked((short)0xF000);
            dggContainer.AddChildRecord(sp);

            r.AddEscherRecord(dggContainer);
            Assert.AreEqual(28, r.RecordSize);

            byte[] data = new byte[28];
            int size = r.Serialize(0, data);
            Assert.AreEqual("[EB, 00, 18, 00, 0F, 00, 00, F0, 10, 00, 00, 00, 11, 11, 0A, F0, 08, 00, 00, 00, FF, FF, FF, FF, FF, FF, FF, FF]", HexDump.ToHex(data));
            Assert.AreEqual(28, size);

            Assert.AreEqual(24, dggContainer.RecordSize);


            r = new DrawingGroupRecord();
            r.RawData = (new byte[MAX_DATA_SIZE]);
            Assert.AreEqual(MAX_RECORD_SIZE, r.RecordSize);
            r.RawData = (new byte[MAX_DATA_SIZE + 1]);
            Assert.AreEqual(MAX_RECORD_SIZE + 5, r.RecordSize);
            r.RawData = (new byte[MAX_DATA_SIZE * 2]);
            Assert.AreEqual(MAX_RECORD_SIZE * 2, r.RecordSize);
            r.RawData = (new byte[MAX_DATA_SIZE * 2 + 1]);
            Assert.AreEqual(MAX_RECORD_SIZE * 2 + 5, r.RecordSize);
        }