public void TestProcessRecords() { bool[] wascalled = { false, }; // hack to pass boolean by ref into inner class ERFListener listener = new ERFListener1(ref wascalled); ArrayList param = new ArrayList(); param.Add(BOFRecord.sid); EventRecordFactory factory = new EventRecordFactory(listener, param); BOFRecord bof = new BOFRecord(); bof.Build = ((short)0); bof.BuildYear = ((short)1999); bof.RequiredVersion = (123); bof.Type = (BOFRecord.TYPE_WORKBOOK); bof.Version = ((short)0x06); bof.HistoryBitMask = (BOFRecord.HISTORY_MASK); EOFRecord eof = EOFRecord.instance; byte[] bytes = new byte[bof.RecordSize + eof.RecordSize]; int offset = 0; offset = bof.Serialize(offset, bytes); offset = eof.Serialize(offset, bytes); factory.ProcessRecords(new MemoryStream(bytes)); Assert.IsTrue(wascalled[0], "The record listener must be called"); }
public void TestCreateRecord() { BOFRecord bof = new BOFRecord(); bof.Build = ((short)0); bof.BuildYear = ((short)1999); bof.RequiredVersion = (123); bof.Type = (BOFRecord.TYPE_WORKBOOK); bof.Version = ((short)0x06); bof.HistoryBitMask = (BOFRecord.HISTORY_MASK); byte[] bytes = bof.Serialize(); Record[] records = RecordFactory.CreateRecord(TestcaseRecordInputStream.Create(bytes)); Assert.IsTrue(records.Length == 1, "record.Length must be 1, was =" + records.Length); Assert.IsTrue(CompareRec(bof, records[0]), "record is the same"); }