public void CanCalculateBlockCheckSize() { BinaryReader br = new BinaryReader(CompressedStream); var header = new XZHeader(br); header.Process(); Assert.That(header.BlockCheckSize, Is.EqualTo(8)); }
public void ProcessesBlockCheckType() { BinaryReader br = new BinaryReader(CompressedStream); var header = new XZHeader(br); header.Process(); Assert.That(header.BlockCheckType, Is.EqualTo(CheckType.CRC64)); }
public void CanCalculateBlockCheckSize() { BinaryReader br = new BinaryReader(CompressedStream); var header = new XZHeader(br); header.Process(); Assert.Equal(8, header.BlockCheckSize); }
public void ProcessesBlockCheckType() { BinaryReader br = new BinaryReader(CompressedStream); var header = new XZHeader(br); header.Process(); Assert.Equal(CheckType.CRC64, header.BlockCheckType); }
public void RecordsStreamStartOnInit() { using (Stream badStream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 })) { BinaryReader br = new BinaryReader(badStream); var header = new XZHeader(br); Assert.That(header.StreamStartPosition, Is.EqualTo(0)); } }
public void RecordsStreamStartOnInit() { using (Stream badStream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 })) { BinaryReader br = new BinaryReader(badStream); var header = new XZHeader(br); Assert.That(header.StreamStartPosition, Is.EqualTo(0)); } }
public void CorruptHeaderThrows() { var bytes = Compressed.Clone() as byte[]; bytes[8]++; using (Stream badCrcStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badCrcStream); var header = new XZHeader(br); var ex = Assert.Throws<InvalidDataException>(() => { header.Process(); }); Assert.That(ex.Message, Is.EqualTo("Stream header corrupt")); } }
public void ChecksMagicNumber() { var bytes = Compressed.Clone() as byte[]; bytes[3]++; using (Stream badMagicNumberStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badMagicNumberStream); var header = new XZHeader(br); var ex = Assert.Throws<InvalidDataException>(() => { header.Process(); }); Assert.That(ex.Message, Is.EqualTo("Invalid XZ Stream")); } }
public void ChecksMagicNumber() { var bytes = Compressed.Clone() as byte[]; bytes[3]++; using (Stream badMagicNumberStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badMagicNumberStream); var header = new XZHeader(br); var ex = Assert.Throws <InvalidDataException>(() => { header.Process(); }); Assert.Equal("Invalid XZ Stream", ex.Message); } }
public void CorruptHeaderThrows() { var bytes = Compressed.Clone() as byte[]; bytes[8]++; using (Stream badCrcStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badCrcStream); var header = new XZHeader(br); var ex = Assert.Throws <InvalidDataException>(() => { header.Process(); }); Assert.Equal("Stream header corrupt", ex.Message); } }
public void BadVersionIfCrcOkButStreamFlagUnknown() { var bytes = Compressed.Clone() as byte[]; byte[] streamFlags = { 0x00, 0xF4 }; byte[] crc = Crc32.Compute(streamFlags).ToLittleEndianBytes(); streamFlags.CopyTo(bytes, 6); crc.CopyTo(bytes, 8); using (Stream badFlagStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badFlagStream); var header = new XZHeader(br); var ex = Assert.Throws<InvalidDataException>(() => { header.Process(); }); Assert.That(ex.Message, Is.EqualTo("Unknown XZ Stream Version")); } }
public void BadVersionIfCrcOkButStreamFlagUnknown() { var bytes = Compressed.Clone() as byte[]; byte[] streamFlags = { 0x00, 0xF4 }; byte[] crc = Crc32.Compute(streamFlags).ToLittleEndianBytes(); streamFlags.CopyTo(bytes, 6); crc.CopyTo(bytes, 8); using (Stream badFlagStream = new MemoryStream(bytes)) { BinaryReader br = new BinaryReader(badFlagStream); var header = new XZHeader(br); var ex = Assert.Throws <InvalidDataException>(() => { header.Process(); }); Assert.Equal("Unknown XZ Stream Version", ex.Message); } }
public void ProcessesStreamHeaderFromFactory() { var header = XZHeader.FromStream(CompressedStream); Assert.Equal(CheckType.CRC64, header.BlockCheckType); }
public void ProcessesStreamHeaderFromFactory() { var header = XZHeader.FromStream(CompressedStream); Assert.That(header.BlockCheckType, Is.EqualTo(CheckType.CRC64)); }