Ejemplo n.º 1
0
        public void TestReadContinued()
        {
            //simulate a continues Drawing record
            MemoryStream out1 = new MemoryStream();
            //main part
            DrawingRecord dg = new DrawingRecord();

            byte[] data1 = new byte[8224];
            Arrays.Fill(data1, (byte)1);
            dg.Data = (/*setter*/ data1);
            byte[] dataX = dg.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            //continued part
            byte[] data2 = new byte[4048];
            Arrays.Fill(data2, (byte)2);
            ContinueRecord cn = new ContinueRecord(data2);

            dataX = cn.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            List <Record> rec = RecordFactory.CreateRecords(new MemoryStream(out1.ToArray()));

            Assert.AreEqual(2, rec.Count);
            Assert.IsTrue(rec[0] is DrawingRecord);
            Assert.IsTrue(rec[1] is ContinueRecord);

            Assert.IsTrue(Arrays.Equals(data1, ((DrawingRecord)rec[0]).Data));
            Assert.IsTrue(Arrays.Equals(data2, ((ContinueRecord)rec[1]).Data));
        }
Ejemplo n.º 2
0
        public void TestReadContinued()
        {
            //simulate a continues Drawing record
            MemoryStream out1 = new MemoryStream();
            //main part
            DrawingRecord dg = new DrawingRecord();

            byte[] data1 = new byte[8224];
            Arrays.Fill(data1, (byte)1);
            dg.Data = (/*setter*/ data1);
            byte[] dataX = dg.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            //continued part
            byte[] data2 = new byte[4048];
            Arrays.Fill(data2, (byte)2);
            ContinueRecord cn = new ContinueRecord(data2);

            dataX = cn.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            List <Record> rec = RecordFactory.CreateRecords(new MemoryStream(out1.ToArray()));

            Assert.AreEqual(1, rec.Count);
            Assert.IsTrue(rec[0] is DrawingRecord);

            //DrawingRecord.Data should return concatenated data1 and data2
            byte[] tmp = new byte[data1.Length + data2.Length];
            Array.Copy(data1, 0, tmp, 0, data1.Length);
            Array.Copy(data2, 0, tmp, data1.Length, data2.Length);

            DrawingRecord dg2 = (DrawingRecord)rec[(0)];

            Assert.AreEqual(data1.Length + data2.Length, dg2.Data.Length);
            Assert.IsTrue(Arrays.Equals(tmp, dg2.Data));
        }