|
|
|
@ -21,7 +21,7 @@ public partial class ImageTests |
|
|
|
|
|
|
|
private static byte[] ActualImageBytes => TestFile.Create(TestImages.Bmp.F).Bytes; |
|
|
|
|
|
|
|
private IImageInfo LocalImageInfo => this.localImageInfoMock.Object; |
|
|
|
private ImageInfo LocalImageInfo => this.localImageInfoMock.Object; |
|
|
|
|
|
|
|
private IImageFormat LocalImageFormat => this.localImageFormatMock.Object; |
|
|
|
|
|
|
|
@ -38,7 +38,7 @@ public partial class ImageTests |
|
|
|
[Fact] |
|
|
|
public void FromBytes_GlobalConfiguration() |
|
|
|
{ |
|
|
|
IImageInfo info = Image.Identify(ActualImageBytes, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(ActualImageBytes, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.Equal(ExpectedImageSize, info.Size()); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, type); |
|
|
|
@ -49,7 +49,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(options, this.ByteArray, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(options, this.ByteArray, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.Equal(this.LocalImageInfo, info); |
|
|
|
Assert.Equal(this.LocalImageFormat, type); |
|
|
|
@ -58,7 +58,7 @@ public partial class ImageTests |
|
|
|
[Fact] |
|
|
|
public void FromFileSystemPath_GlobalConfiguration() |
|
|
|
{ |
|
|
|
IImageInfo info = Image.Identify(ActualImagePath, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(ActualImagePath, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, type); |
|
|
|
@ -69,7 +69,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(options, this.MockFilePath, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(options, this.MockFilePath, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.Equal(this.LocalImageInfo, info); |
|
|
|
Assert.Equal(this.LocalImageFormat, type); |
|
|
|
@ -79,7 +79,7 @@ public partial class ImageTests |
|
|
|
public void FromStream_GlobalConfiguration() |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
IImageInfo info = Image.Identify(stream, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(stream, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, type); |
|
|
|
@ -89,7 +89,7 @@ public partial class ImageTests |
|
|
|
public void FromStream_GlobalConfiguration_NoFormat() |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
IImageInfo info = Image.Identify(stream); |
|
|
|
ImageInfo info = Image.Identify(stream); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
} |
|
|
|
@ -100,7 +100,7 @@ public partial class ImageTests |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
using var nonSeekableStream = new NonSeekableStream(stream); |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(nonSeekableStream, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(nonSeekableStream, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, type); |
|
|
|
@ -112,7 +112,7 @@ public partial class ImageTests |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
using var nonSeekableStream = new NonSeekableStream(stream); |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(nonSeekableStream); |
|
|
|
ImageInfo info = Image.Identify(nonSeekableStream); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
} |
|
|
|
@ -122,7 +122,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(options, this.DataStream, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(options, this.DataStream, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.Equal(this.LocalImageInfo, info); |
|
|
|
Assert.Equal(this.LocalImageFormat, type); |
|
|
|
@ -133,7 +133,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(options, this.DataStream); |
|
|
|
ImageInfo info = Image.Identify(options, this.DataStream); |
|
|
|
|
|
|
|
Assert.Equal(this.LocalImageInfo, info); |
|
|
|
} |
|
|
|
@ -143,7 +143,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = new() }; |
|
|
|
|
|
|
|
IImageInfo info = Image.Identify(options, this.DataStream, out IImageFormat type); |
|
|
|
ImageInfo info = Image.Identify(options, this.DataStream, out IImageFormat type); |
|
|
|
|
|
|
|
Assert.Null(info); |
|
|
|
Assert.Null(type); |
|
|
|
@ -168,7 +168,7 @@ public partial class ImageTests |
|
|
|
0x00, 0x00, 0x00, 0x00 |
|
|
|
})); |
|
|
|
using Stream stream = zipFile.Entries[0].Open(); |
|
|
|
IImageInfo info = Image.Identify(stream); |
|
|
|
ImageInfo info = Image.Identify(stream); |
|
|
|
Assert.Null(info); |
|
|
|
} |
|
|
|
|
|
|
|
@ -177,7 +177,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
var asyncStream = new AsyncStreamWrapper(stream, () => false); |
|
|
|
IImageInfo info = await Image.IdentifyAsync(asyncStream); |
|
|
|
ImageInfo info = await Image.IdentifyAsync(asyncStream); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
} |
|
|
|
@ -187,7 +187,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(ActualImageBytes); |
|
|
|
var asyncStream = new AsyncStreamWrapper(stream, () => false); |
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(asyncStream); |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(asyncStream); |
|
|
|
|
|
|
|
Assert.Equal(ExpectedImageSize, res.ImageInfo.Size()); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, res.Format); |
|
|
|
@ -200,7 +200,7 @@ public partial class ImageTests |
|
|
|
using var nonSeekableStream = new NonSeekableStream(stream); |
|
|
|
|
|
|
|
var asyncStream = new AsyncStreamWrapper(nonSeekableStream, () => false); |
|
|
|
IImageInfo info = await Image.IdentifyAsync(asyncStream); |
|
|
|
ImageInfo info = await Image.IdentifyAsync(asyncStream); |
|
|
|
|
|
|
|
Assert.NotNull(info); |
|
|
|
} |
|
|
|
@ -212,7 +212,7 @@ public partial class ImageTests |
|
|
|
using var nonSeekableStream = new NonSeekableStream(stream); |
|
|
|
|
|
|
|
var asyncStream = new AsyncStreamWrapper(nonSeekableStream, () => false); |
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(asyncStream); |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(asyncStream); |
|
|
|
|
|
|
|
Assert.Equal(ExpectedImageSize, res.ImageInfo.Size()); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, res.Format); |
|
|
|
@ -237,7 +237,7 @@ public partial class ImageTests |
|
|
|
0x00, 0x00, 0x00, 0x00 |
|
|
|
})); |
|
|
|
using Stream stream = zipFile.Entries[0].Open(); |
|
|
|
IImageInfo info = await Image.IdentifyAsync(stream); |
|
|
|
ImageInfo info = await Image.IdentifyAsync(stream); |
|
|
|
Assert.Null(info); |
|
|
|
} |
|
|
|
|
|
|
|
@ -246,7 +246,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
IImageInfo info = await Image.IdentifyAsync(options, this.MockFilePath); |
|
|
|
ImageInfo info = await Image.IdentifyAsync(options, this.MockFilePath); |
|
|
|
Assert.Equal(this.LocalImageInfo, info); |
|
|
|
} |
|
|
|
|
|
|
|
@ -255,7 +255,7 @@ public partial class ImageTests |
|
|
|
{ |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) info = |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) info = |
|
|
|
await Image.IdentifyWithFormatAsync(options, this.MockFilePath); |
|
|
|
Assert.NotNull(info.ImageInfo); |
|
|
|
Assert.Equal(this.LocalImageFormat, info.Format); |
|
|
|
@ -264,7 +264,7 @@ public partial class ImageTests |
|
|
|
[Fact] |
|
|
|
public async Task IdentifyWithFormatAsync_FromPath_GlobalConfiguration() |
|
|
|
{ |
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(ActualImagePath); |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) res = await Image.IdentifyWithFormatAsync(ActualImagePath); |
|
|
|
|
|
|
|
Assert.Equal(ExpectedImageSize, res.ImageInfo.Size()); |
|
|
|
Assert.Equal(ExpectedGlobalFormat, res.Format); |
|
|
|
@ -273,7 +273,7 @@ public partial class ImageTests |
|
|
|
[Fact] |
|
|
|
public async Task FromPathAsync_GlobalConfiguration() |
|
|
|
{ |
|
|
|
IImageInfo info = await Image.IdentifyAsync(ActualImagePath); |
|
|
|
ImageInfo info = await Image.IdentifyAsync(ActualImagePath); |
|
|
|
|
|
|
|
Assert.Equal(ExpectedImageSize, info.Size()); |
|
|
|
} |
|
|
|
@ -284,7 +284,7 @@ public partial class ImageTests |
|
|
|
DecoderOptions options = new() { Configuration = this.LocalConfiguration }; |
|
|
|
|
|
|
|
var asyncStream = new AsyncStreamWrapper(this.DataStream, () => false); |
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) |
|
|
|
info = await Image.IdentifyWithFormatAsync(options, asyncStream); |
|
|
|
|
|
|
|
Assert.Equal(this.LocalImageInfo, info.ImageInfo); |
|
|
|
@ -297,7 +297,7 @@ public partial class ImageTests |
|
|
|
DecoderOptions options = new() { Configuration = new() }; |
|
|
|
|
|
|
|
var asyncStream = new AsyncStreamWrapper(this.DataStream, () => false); |
|
|
|
(IImageInfo ImageInfo, IImageFormat Format) |
|
|
|
(ImageInfo ImageInfo, IImageFormat Format) |
|
|
|
info = await Image.IdentifyWithFormatAsync(options, asyncStream); |
|
|
|
|
|
|
|
Assert.Null(info.ImageInfo); |
|
|
|
|