示例#1
0
        public void TestRemoveRecord()
        {
            byte[]         wbBytes = TestHelpers.GetMacroTestBytes();
            WorkbookStream wbs     = new WorkbookStream(wbBytes);

            BiffRecord     haltRecord = wbs.GetAllRecordsByType <Formula>().Last();
            List <Formula> formulas   = wbs.GetAllRecordsByType <Formula>();

            Assert.AreEqual(3, formulas.Count);
            wbs = wbs.RemoveRecord(haltRecord);

            formulas = wbs.GetAllRecordsByType <Formula>();
            Assert.AreEqual(2, formulas.Count);

            foreach (var formula in formulas)
            {
                List <AbstractPtg> ptgs  = formula.ptgStack.ToList();
                List <PtgFunc>     funcs = ptgs.Where(p => p.Id == PtgNumber.PtgFunc).Cast <PtgFunc>().ToList();
                bool haltFunctionExists  = funcs.Any(func => func.Ftab == FtabValues.HALT);
                Assert.AreEqual(false, haltFunctionExists);
            }
        }