public void TgaDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); ImageFormatException ex = Assert.Throws <ImageFormatException>(() => provider.GetImage(TgaDecoder)); Assert.IsType <InvalidMemoryOperationException>(ex.InnerException); }
public void DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { provider.LimitAllocatorBufferCapacity().InBytesSqrt(10); ImageFormatException ex = Assert.Throws <ImageFormatException>(() => provider.GetImage(JpegDecoder)); this.Output.WriteLine(ex.Message); Assert.IsType <InvalidMemoryOperationException>(ex.InnerException); }
[InlineData((uint)PngChunkType.End)] // IEND public void Decode_IncorrectCRCForCriticalChunk_ExceptionIsThrown(uint chunkType) { string chunkName = GetChunkTypeName(chunkType); using (var memStream = new MemoryStream()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); WriteDataChunk(memStream); var decoder = new PngDecoder(); ImageFormatException exception = Assert.Throws <ImageFormatException>(() => decoder.Decode <Rgb24>(null, memStream)); Assert.Equal($"CRC Error. PNG {chunkName} chunk is corrupt!", exception.Message); } }
public void Decode_IncorrectCRCForCriticalChunk_ExceptionIsThrown(string chunkName) { using (var memStream = new MemoryStream()) { memStream.Skip(8); WriteChunk(memStream, chunkName); CompressStream(memStream); var decoder = new PngDecoder(); ImageFormatException exception = Assert.Throws <ImageFormatException>(() => { decoder.Decode <Rgb24>(null, memStream); }); Assert.Equal($"CRC Error. PNG {chunkName} chunk is corrupt!", exception.Message); } }