public void TestRecalcId() { HSSFWorkbook wb = new HSSFWorkbook(); Assert.IsFalse(wb.ForceFormulaRecalculation); InternalWorkbook iwb = TestHSSFWorkbook.GetInternalWorkbook(wb); int countryPos = iwb.FindFirstRecordLocBySid(CountryRecord.sid); Assert.IsTrue(countryPos != -1); // RecalcIdRecord is not present in new workbooks Assert.AreEqual(null, iwb.FindFirstRecordBySid(RecalcIdRecord.sid)); RecalcIdRecord record = iwb.RecalcId; Assert.IsNotNull(record); Assert.AreSame(record, iwb.RecalcId); Assert.AreSame(record, iwb.FindFirstRecordBySid(RecalcIdRecord.sid)); Assert.AreEqual(countryPos + 1, iwb.FindFirstRecordLocBySid(RecalcIdRecord.sid)); record.EngineId = (/*setter*/ 100); Assert.AreEqual(100, record.EngineId); Assert.IsTrue(wb.ForceFormulaRecalculation); wb.ForceFormulaRecalculation = (/*setter*/ true); // resets the EngineId flag to zero Assert.AreEqual(0, record.EngineId); Assert.IsFalse(wb.ForceFormulaRecalculation); wb.Close(); }
public void TestBadFirstField_bug48096() { /** * Data taken from the sample file referenced in Bugzilla 48096, file offset 0x0D45. * The apparent problem is that the first data short field has been written with the * wrong <i>endianness</n>. Excel seems to ignore whatever value is present in this * field, and always reWrites it as (C1, 01). POI now does the same. */ byte[] badData = HexRead.ReadFromString("C1 01 08 00 01 C1 00 00 00 01 69 61"); byte[] goodData = HexRead.ReadFromString("C1 01 08 00 C1 01 00 00 00 01 69 61"); RecordInputStream in1 = TestcaseRecordInputStream.Create(badData); RecalcIdRecord r; try { r = new RecalcIdRecord(in1); } catch (RecordFormatException e) { if (e.Message.Equals("expected 449 but got 49409")) { throw new AssertionException("Identified bug 48096"); } throw e; } Assert.AreEqual(0, in1.Remaining); Assert.IsTrue(Arrays.Equals(r.Serialize(), goodData)); }
private static RecalcIdRecord Create(byte[] data) { RecordInputStream in1 = TestcaseRecordInputStream.Create(RecalcIdRecord.sid, data); RecalcIdRecord result = new RecalcIdRecord(in1); Assert.AreEqual(0, in1.Remaining); return(result); }
public void TestBasicDeSerializeReserialize() { byte[] data = HexRead.ReadFromString( "C1 01" + // rt "00 00" + // reserved "1D EB 01 00"); // engine id RecalcIdRecord r = Create(data); TestcaseRecordInputStream.ConfirmRecordEncoding(RecalcIdRecord.sid, data, r.Serialize()); }