Exemplo n.º 1
0
        public void TestCreateCFRuleRecord()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet    sheet    = (HSSFSheet)workbook.CreateSheet();
            CFRuleRecord record   = CFRuleRecord.Create(sheet, "7");

            TestCFRuleRecord1(record);

            // Serialize
            byte[] SerializedRecord = record.Serialize();

            // Strip header
            byte[] recordData = new byte[SerializedRecord.Length - 4];
            Array.Copy(SerializedRecord, 4, recordData, 0, recordData.Length);

            // DeSerialize
            record = new CFRuleRecord(TestcaseRecordInputStream.Create(CFRuleRecord.sid, recordData));

            // Serialize again
            byte[] output = record.Serialize();

            // Compare
            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], "CFRuleRecord doesn't match");
            }
        }
Exemplo n.º 2
0
        public void TestBug53691()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet    sheet    = workbook.CreateSheet() as HSSFSheet;

            CFRuleRecord record = CFRuleRecord.Create(sheet, (byte)ComparisonOperator.Between, "2", "5") as CFRuleRecord;

            CFRuleRecord clone = (CFRuleRecord)record.Clone();

            byte[] SerializedRecord = record.Serialize();
            byte[] SerializedClone  = clone.Serialize();
            Assert.That(SerializedRecord, new EqualConstraint(SerializedClone));
        }
Exemplo n.º 3
0
        public void TestReserializeRefNTokens()
        {
            RecordInputStream is1 = TestcaseRecordInputStream.Create(CFRuleRecord.sid, DATA_REFN);
            CFRuleRecord      rr  = new CFRuleRecord(is1);

            Ptg[] ptgs = rr.ParsedExpression1;
            Assert.AreEqual(3, ptgs.Length);
            if (ptgs[0] is RefPtg)
            {
                throw new AssertionException("Identified bug 45234");
            }
            Assert.AreEqual(typeof(RefNPtg), ptgs[0].GetType());
            RefNPtg refNPtg = (RefNPtg)ptgs[0];

            Assert.IsTrue(refNPtg.IsColRelative);
            Assert.IsTrue(refNPtg.IsRowRelative);

            byte[] data = rr.Serialize();

            TestcaseRecordInputStream.ConfirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
        }
Exemplo n.º 4
0
        public void TestWrite()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            CFRuleRecord rr       = CFRuleRecord.Create(workbook, ComparisonOperator.BETWEEN, "5", "10");

            PatternFormatting patternFormatting = new PatternFormatting();

            patternFormatting.FillPattern = (PatternFormatting.BRICKS);
            rr.PatternFormatting          = (patternFormatting);

            byte[] data = rr.Serialize();
            Assert.AreEqual(26, data.Length);
            Assert.AreEqual(3, LittleEndian.GetShort(data, 6));
            Assert.AreEqual(3, LittleEndian.GetShort(data, 8));

            int flags = LittleEndian.GetInt(data, 10);

            Assert.AreEqual(0x00380000, flags & 0x00380000, "unused flags should be 111");
            Assert.AreEqual(0, flags & 0x03C00000, "undocumented flags should be 0000");        // Otherwise Excel s unhappy
            // check all remaining flag bits (some are not well understood yet)
            Assert.AreEqual(0x203FFFFF, flags);
        }
Exemplo n.º 5
0
        public void TestReserializeRefNTokens()
        {
            RecordInputStream is1 = TestcaseRecordInputStream.Create(CFRuleRecord.sid, DATA_REFN);
            CFRuleRecord      rr  = new CFRuleRecord(is1);

            Ptg[] ptgs = rr.ParsedExpression1;
            Assert.AreEqual(3, ptgs.Length);
            if (ptgs[0] is RefPtg)
            {
                throw new AssertFailedException("Identified bug 45234");
            }
            Assert.AreEqual(typeof(RefNPtg), ptgs[0].GetType());
            RefNPtg refNPtg = (RefNPtg)ptgs[0];

            Assert.IsTrue(refNPtg.IsColRelative);
            Assert.IsTrue(refNPtg.IsRowRelative);

            byte[] data = rr.Serialize();

            if (!CompareArrays(DATA_REFN, 0, data, 4, DATA_REFN.Length))
            {
                Assert.Fail("Did not re-serialize correctly");
            }
        }