public void ZipReadOnlyStorer_ReadNoValidEndOfCentralDirectoryRecordSignature_Exception() { byte[] data = zip64OneFileStore.Clone() as byte[]; data[328] = 0; Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data)); }
public void ZipReadOnlyStorer_ReadInvalidLocalFileHeaderSignature_Exception() { byte[] data = zip64OneFileStore.Clone() as byte[]; data[0] = 0; Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data)); }
public void ZipReadOnlyStorer_ReadInvalidCentralDirectoryZip64LocatorSignature_Exception() { byte[] data = zip64OneFileStore.Clone() as byte[]; data[308] = 0; Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(data)); }
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); }
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))); }
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)); }
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); }
public void Zip32ReadOnlyStorer_Empty_IsZip32() { ZipReadOnlyStorer storer = ZipReadOnlyStorer.FromData(zip32Empty) as ZipReadOnlyStorer; Assert.False(storer.IsZip64); }
public void ZipReadOnlyStorer_ReadDataLessThan22_Exception() { Assert.Throws <InvalidDataException>(() => ZipReadOnlyStorer.FromData(new byte[21])); }
public void ZipReadOnlyStorer_ReadEntryNull_ValidateNotNull() { AssertValidation.NotNull( () => ZipReadOnlyStorer.FromData(zip32Empty).Read(null), "Entry"); }
public void ZipReadOnlyStorer_FromDataNull_ValidateNotNull() { AssertValidation.NotNull( () => ZipReadOnlyStorer.FromData(null), "Data"); }
/// <inheritdoc/> protected override IReadOnlyDataStorer CreateReadOnlyDataStorer(byte[] data) { return(ZipReadOnlyStorer.FromData(data)); }