~ubuntu-branches/ubuntu/wily/openmcdf/wily

« back to all changes in this revision

Viewing changes to src/OLECFSTest/CFSStreamTest.cs

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-04-08 11:02:15 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130408110215-aleqo4zhjc3qgxnb
Tags: 1.5.4-1
* New upstream: 1.5.4
  - Use Hexbox for hexadecimal viewing

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
 
133
133
            try
134
134
            {
135
 
                myStream.SetData(b);
 
135
                myStream.SetData(b); cf.Save("ZERO_LENGTH_STREAM.cfs");
136
136
            }
137
137
            catch
138
138
            {
139
139
                Assert.Fail("Failed setting zero length stream");
140
140
            }
141
 
 
142
 
            cf.Save("ZERO_LENGTH_STREAM.cfs");
143
 
            cf.Close();
 
141
            finally
 
142
            {
 
143
                if (cf != null)
 
144
                    cf.Close();
 
145
            }
 
146
 
 
147
            if (File.Exists("ZERO_LENGTH_STREAM.cfs"))
 
148
                File.Delete("ZERO_LENGTH_STREAM.cfs");
 
149
 
144
150
        }
145
151
 
146
152
        [TestMethod]
184
190
            {
185
191
                cfo.Close();
186
192
            }
 
193
 
 
194
            if (File.Exists("ZERO_LENGTH_STREAM_RE.cfs"))
 
195
                File.Delete("ZERO_LENGTH_STREAM_RE.cfs");
 
196
 
 
197
            if (File.Exists("ZERO_LENGTH_STREAM_RE2.cfs"))
 
198
                File.Delete("ZERO_LENGTH_STREAM_RE2.cfs");
 
199
 
187
200
        }
188
201
 
189
202
 
212
225
            Assert.IsTrue(Helpers.CompareBuffer(b, st.GetData()));
213
226
 
214
227
            cf2.Close();
 
228
 
 
229
            if (File.Exists("WRITE_STREAM_WITH_DIFAT.cfs"))
 
230
                File.Delete("WRITE_STREAM_WITH_DIFAT.cfs");
 
231
 
215
232
        }
216
233
 
217
234
 
286
303
            Assert.IsTrue(Helpers.CompareBuffer(bufferB, bufferC), "DATA INTEGRITY FAILED");
287
304
 
288
305
            cfc.Close();
 
306
 
 
307
            if (File.Exists("WRITE_MINISTREAM_READ_REWRITE_STREAM.cfs"))
 
308
                File.Delete("WRITE_MINISTREAM_READ_REWRITE_STREAM.cfs");
 
309
 
 
310
 
 
311
            if (File.Exists("WRITE_MINISTREAM_READ_REWRITE_STREAM_2ND.cfs"))
 
312
                File.Delete("WRITE_MINISTREAM_READ_REWRITE_STREAM_2ND.cfs");
 
313
 
289
314
        }
290
315
 
291
316
        [TestMethod]
307
332
            byte[] c = cf.RootStorage.GetStream("Workbook").GetData();
308
333
            Assert.IsTrue(c.Length == BUFFER_LENGTH);
309
334
            cf.Close();
 
335
 
 
336
            if (File.Exists("reportRW_SMALL.xls"))
 
337
                File.Delete("reportRW_SMALL.xls");
 
338
 
310
339
        }
311
340
 
312
341
        [TestMethod]
327
356
            byte[] c = cf.RootStorage.GetStream("\x05SummaryInformation").GetData();
328
357
            Assert.IsTrue(c.Length == TEST_LENGTH);
329
358
            cf.Close();
 
359
 
 
360
            if (File.Exists("RE_WRITE_SMALLER_MINI_STREAM.xls"))
 
361
                File.Delete("RE_WRITE_SMALLER_MINI_STREAM.xls");
 
362
 
330
363
        }
331
364
 
332
365
        [TestMethod]
346
379
 
347
380
            cf.Commit();
348
381
            cf.Close();
 
382
 
 
383
 
 
384
            if (File.Exists("reportOverwrite.xls"))
 
385
                File.Delete("reportOverwrite.xls");
 
386
 
349
387
        }
350
388
 
351
389
        [TestMethod]
389
427
 
390
428
            cf.Save(dstFilename + "PP");
391
429
            cf.Close();
 
430
 
 
431
            if (File.Exists("reportOverwriteMultiple.xls"))
 
432
                File.Delete("reportOverwriteMultiple.xls");
 
433
 
 
434
            if (File.Exists("reportOverwriteMultiple.xlsPP"))
 
435
                File.Delete("reportOverwriteMultiple.xlsPP");
 
436
 
 
437
 
392
438
        }
393
439
 
394
440
        [TestMethod]
417
463
 
418
464
            larger.Close();
419
465
            smaller.Close();
 
466
 
 
467
            if (File.Exists("reportOverwriteMultiple.xlsPP"))
 
468
                File.Delete("reportOverwriteMultiple.xlsPP");
 
469
 
 
470
 
420
471
        }
421
472
 
422
473
        [TestMethod]
438
489
 
439
490
            cf.Commit();
440
491
            cf.Close();
 
492
 
 
493
            if (File.Exists("reportOverwrite2.xlsPP"))
 
494
                File.Delete("reportOverwrite2.xlsPP");
 
495
 
 
496
 
441
497
        }
442
498
 
443
499
 
484
540
            sm.SetData(b);
485
541
 
486
542
            cf.Save(filename);
 
543
            cf.Close();
487
544
 
488
545
            CompoundFile cf2 = new CompoundFile(filename);
489
546
            CFStorage st2 = cf2.RootStorage.GetStorage("MyStorage");
490
547
            CFStream sm2 = st2.GetStream("MyStream");
 
548
            cf2.Close();
491
549
 
492
550
            Assert.IsNotNull(sm2);
493
551
            Assert.IsTrue(sm2.Size == 220);
 
552
 
 
553
 
 
554
            if (File.Exists(filename))
 
555
                File.Delete(filename);
 
556
 
 
557
 
494
558
        }
495
559
 
496
560
        [TestMethod]
701
765
 
702
766
            cf = new CompoundFile("COPY_FROM_STREAM.cfs");
703
767
            byte[] data = cf.RootStorage.GetStream("MyImportedStream").GetData();
704
 
            
 
768
 
705
769
            Assert.IsTrue(Helpers.CompareBuffer(b, data));
706
770
 
707
771
        }