Beispiel #1
0
        public void TestSerialization()
        {
            byte[] recordData = 
		    {
			    (byte)0x03, (byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
    			
			    (byte)0x04,	(byte)0x00, // nRegions
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
    			
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
		    };

            CFHeaderRecord record = new CFHeaderRecord(TestcaseRecordInputStream.Create(CFHeaderRecord.sid, recordData));

            Assert.AreEqual(3, record.NumberOfConditionalFormats, "#CFRULES");
            Assert.IsTrue(record.NeedRecalculation);
            Confirm(record.EnclosingCellRange, 0, 3, 0, 3);
            CellRangeAddress[] ranges = record.CellRanges;
            Assert.AreEqual(4, ranges.Length);
            Confirm(ranges[0], 0, 1, 0, 1);
            Confirm(ranges[1], 0, 1, 2, 3);
            Confirm(ranges[2], 2, 3, 0, 1);
            Confirm(ranges[3], 2, 3, 2, 3);
            Assert.AreEqual(recordData.Length + 4, record.RecordSize);

            byte[] output = record.Serialize();

            Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength

            for (int i = 0; i < recordData.Length; i++)
            {
                Assert.AreEqual(recordData[i], output[i + 4], "CFHeaderRecord doesn't match");
            }
        }
Beispiel #2
0
        public void TestExtremeRows()
        {
            byte[] recordData = {
			    (byte)0x13, (byte)0x00, // nFormats
			    (byte)0x00,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0xFF,
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0x00,
    			
			    (byte)0x03,	(byte)0x00, // nRegions
    			
			    (byte)0x40,	(byte)0x9C,
			    (byte)0x50,	(byte)0xC3,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0xFF,
			    (byte)0x05,	(byte)0x00,
			    (byte)0x05,	(byte)0x00,
    			
			    (byte)0x07,	(byte)0x00,
			    (byte)0x07,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0x00,
		    };

            CFHeaderRecord record;
            try
            {
                record = new CFHeaderRecord(TestcaseRecordInputStream.Create(CFHeaderRecord.sid, recordData));
            }
            catch (ArgumentException e)
            {
                if (e.Message.Equals("invalid cell range (-25536, 2, -15536, 2)"))
                {
                    throw new AssertionException("Identified bug 44739b");
                }
                throw e;
            }

            Assert.AreEqual(19, record.NumberOfConditionalFormats, "#CFRULES");
            Assert.IsFalse(record.NeedRecalculation);
            Confirm(record.EnclosingCellRange, 0, 65535, 0, 255);
            CellRangeAddress[] ranges = record.CellRanges;
            Assert.AreEqual(3, ranges.Length);
            Confirm(ranges[0], 40000, 50000, 2, 2);
            Confirm(ranges[1], 0, 65535, 5, 5);
            Confirm(ranges[2], 7, 7, 0, 255);

            byte[] output = record.Serialize();

            Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength

            for (int i = 0; i < recordData.Length; i++)
            {
                Assert.AreEqual(recordData[i], output[i + 4], "CFHeaderRecord doesn't match");
            }
        }