예제 #1
0
 public void CopyFromMappedFileTest()
 {
     try
     {
         ZipFile zfile = new ZipFile();
         zfile.Start = 0;
         zfile.Size  = 11;
         zfile.File  = new FileInfo($"{testfiles}testresults/testfile");
         using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile($"{testfiles}testdir/testfile", FileMode.Open))
         {
             zfile.CopyFromMappedFile(mmf);
         }
         using (StreamReader stream = new StreamReader(File.Open($"{testfiles}testresults/testfile", FileMode.Open)))
         {
             if (stream.ReadLine() != "testcontent")
             {
                 Assert.Fail();
             }
         }
     }
     finally
     {
         File.Delete($"{testfiles}testresults/testfile");
     }
 }
예제 #2
0
        public void CopyFromMappedFileThrowTest()
        {
            ZipFile zfile = new ZipFile();

            zfile.Start = 0;
            zfile.Size  = 12;
            zfile.File  = new FileInfo($"{testfiles}testresults/testfile");
            using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile($"{testfiles}testdir/testfile", FileMode.Open))
            {
                try
                {
                    zfile.CopyFromMappedFile(mmf);
                    Assert.Fail();
                }
                catch (CorruptionException) { }
            }
        }