예제 #1
0
        public void ZipReadOnlyStorer_ReadNoValidEndOfCentralDirectoryRecordSignature_Exception()
        {
            byte[] data = zip64OneFileStore.Clone() as byte[];
            data[328] = 0;

            Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data));
        }
예제 #2
0
        public void ZipReadOnlyStorer_ReadInvalidLocalFileHeaderSignature_Exception()
        {
            byte[] data = zip64OneFileStore.Clone() as byte[];
            data[0] = 0;

            Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data));
        }
예제 #3
0
        public void ZipReadOnlyStorer_ReadInvalidCentralDirectoryZip64LocatorSignature_Exception()
        {
            byte[] data = zip64OneFileStore.Clone() as byte[];
            data[308] = 0;

            Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data));
        }
예제 #4
0
        public void ZipReadOnlyStorer_InvalidEntry_Exception()
        {
            var entry = new InvalidZipEntry()
            {
                Path = "File.data"
            };

            var ex = Assert.Throws <InvalidEntryException>(() => ZipReadOnlyStorer.FromData(zip32Empty).Read(entry));

            ex.AssertArguments(entry.Path);
        }
예제 #5
0
        private void ZipReadOnlyStorer_OneFile_Test(bool isZip64, bool enableCompression)
        {
            byte[] data = null;

            if (isZip64)
            {
                data = enableCompression ? zip64OneFileDeflate : zip64OneFileStore;
            }
            else
            {
                data = enableCompression ? zip32OneFileDeflate : zip32OneFileStore;
            }

            IReadOnlyDataStorer storer = ZipReadOnlyStorer.FromData(data);

            ZipReadOnlyStorerEntry entry = storer.Entries.FindOrDefault(e => e.Path == filePath1) as ZipReadOnlyStorerEntry;

            Assert.NotNull(fileData.SequenceEqual(storer.Read(entry)));
        }
예제 #6
0
        private void ZipReadOnlyStorer_OneFile_Test(bool isZip64, bool enableCompression, Func <ZipReadOnlyStorerEntry, object> selectValue, object value)
        {
            byte[] data = null;

            if (isZip64)
            {
                data = enableCompression ? zip64OneFileDeflate : zip64OneFileStore;
            }
            else
            {
                data = enableCompression ? zip32OneFileDeflate : zip32OneFileStore;
            }

            IReadOnlyDataStorer storer = ZipReadOnlyStorer.FromData(data);

            ZipReadOnlyStorerEntry entry = storer.Entries.FindOrDefault(e => e.Path == filePath1) as ZipReadOnlyStorerEntry;

            Assert.AreEqual(value, selectValue(entry));
        }
예제 #7
0
        private void ZipReadOnlyStorer_TwoFiles_Test(bool isZip64, bool enableCompression)
        {
            byte[] data = null;

            if (isZip64)
            {
                data = enableCompression ? zip64TwoFilesDeflate : zip64TwoFilesStore;
            }
            else
            {
                data = enableCompression ? zip32TwoFilesDeflate : zip32TwoFilesStore;
            }

            IReadOnlyDataStorer storer = ZipReadOnlyStorer.FromData(data);

            IReadOnlyList <IDataStorerEntry> entries = storer.Entries;
            ZipReadOnlyStorerEntry           entry1  = entries.FindOrDefault(e => e.Path == filePath1) as ZipReadOnlyStorerEntry;
            ZipReadOnlyStorerEntry           entry2  = entries.FindOrDefault(e => e.Path == filePath2) as ZipReadOnlyStorerEntry;

            Assert.NotNull(fileData.SequenceEqual(storer.Read(entry1)));
            Assert.NotNull(fileData.SequenceEqual(storer.Read(entry2)));
        }
        public void Zip64ReadOnlyStorer_Empty_IsZip64()
        {
            ZipReadOnlyStorer storer = ZipReadOnlyStorer.FromData(zip64Empty) as ZipReadOnlyStorer;

            Assert.True(storer.IsZip64);
        }
        public void Zip64ReadOnlyStorer_Empty_NoEntries()
        {
            IReadOnlyDataStorer storer = ZipReadOnlyStorer.FromData(zip64Empty);

            Assert.Zero(storer.Entries.Count);
        }
예제 #10
0
        public void Zip32ReadOnlyStorer_Empty_IsZip32()
        {
            ZipReadOnlyStorer storer = ZipReadOnlyStorer.FromData(zip32Empty) as ZipReadOnlyStorer;

            Assert.False(storer.IsZip64);
        }
예제 #11
0
 public void ZipReadOnlyStorer_ReadDataLessThan22_Exception()
 {
     Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(new byte[21]));
 }
예제 #12
0
 public void ZipReadOnlyStorer_ReadEntryNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => ZipReadOnlyStorer.FromData(zip32Empty).Read(null),
         "Entry");
 }
예제 #13
0
 public void ZipReadOnlyStorer_FromDataNull_ValidateNotNull()
 {
     AssertValidation.NotNull(
         () => ZipReadOnlyStorer.FromData(null),
         "Data");
 }
예제 #14
0
 /// <inheritdoc/>
 protected override IReadOnlyDataStorer CreateReadOnlyDataStorer(byte[] data)
 {
     return(ZipReadOnlyStorer.FromData(data));
 }