|
|
|
@ -25,13 +25,13 @@ public partial class ImageTests |
|
|
|
|
|
|
|
protected Mock<IImageFormat> localImageFormatMock; |
|
|
|
|
|
|
|
protected Mock<ImageInfo> localImageInfoMock; |
|
|
|
protected Mock<IImageInfo> localImageInfoMock; |
|
|
|
|
|
|
|
protected readonly string MockFilePath = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
internal readonly Mock<IFileSystem> LocalFileSystemMock = new Mock<IFileSystem>(); |
|
|
|
internal readonly Mock<IFileSystem> LocalFileSystemMock = new(); |
|
|
|
|
|
|
|
protected readonly TestFileSystem topLevelFileSystem = new TestFileSystem(); |
|
|
|
protected readonly TestFileSystem topLevelFileSystem = new(); |
|
|
|
|
|
|
|
public Configuration LocalConfiguration { get; } |
|
|
|
|
|
|
|
@ -56,21 +56,29 @@ public partial class ImageTests |
|
|
|
this.localStreamReturnImageRgba32 = new Image<Rgba32>(1, 1); |
|
|
|
this.localStreamReturnImageAgnostic = new Image<Bgra4444>(1, 1); |
|
|
|
|
|
|
|
this.localImageInfoMock = new Mock<ImageInfo>(); |
|
|
|
this.localImageInfoMock = new Mock<IImageInfo>(); |
|
|
|
this.localImageFormatMock = new Mock<IImageFormat>(); |
|
|
|
|
|
|
|
this.localDecoder = new Mock<IImageDecoder>(); |
|
|
|
this.localDecoder.Setup(x => x.Identify(It.IsAny<DecoderOptions>(), It.IsAny<Stream>())) |
|
|
|
.Returns(this.localImageInfoMock.Object); |
|
|
|
.Returns(() => |
|
|
|
{ |
|
|
|
IImageInfo info = this.localImageInfoMock.Object; |
|
|
|
return new ImageInfo(info.PixelType, info.Width, info.Height, info.Metadata); |
|
|
|
}); |
|
|
|
|
|
|
|
this.localDecoder.Setup(x => x.IdentifyAsync(It.IsAny<DecoderOptions>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>())) |
|
|
|
.Returns(Task.FromResult(this.localImageInfoMock.Object)); |
|
|
|
.Returns(() => |
|
|
|
{ |
|
|
|
IImageInfo info = this.localImageInfoMock.Object; |
|
|
|
return Task.FromResult(new ImageInfo(info.PixelType, info.Width, info.Height, info.Metadata)); |
|
|
|
}); |
|
|
|
|
|
|
|
this.localDecoder |
|
|
|
.Setup(x => x.Decode<Rgba32>(It.IsAny<DecoderOptions>(), It.IsAny<Stream>())) |
|
|
|
.Callback<DecoderOptions, Stream>((c, s) => |
|
|
|
.Callback<DecoderOptions, Stream>((_, s) => |
|
|
|
{ |
|
|
|
using var ms = new MemoryStream(); |
|
|
|
using MemoryStream ms = new(); |
|
|
|
s.CopyTo(ms); |
|
|
|
this.DecodedData = ms.ToArray(); |
|
|
|
}) |
|
|
|
@ -78,9 +86,9 @@ public partial class ImageTests |
|
|
|
|
|
|
|
this.localDecoder |
|
|
|
.Setup(x => x.Decode(It.IsAny<DecoderOptions>(), It.IsAny<Stream>())) |
|
|
|
.Callback<DecoderOptions, Stream>((c, s) => |
|
|
|
.Callback<DecoderOptions, Stream>((_, s) => |
|
|
|
{ |
|
|
|
using var ms = new MemoryStream(); |
|
|
|
using MemoryStream ms = new(); |
|
|
|
s.CopyTo(ms); |
|
|
|
this.DecodedData = ms.ToArray(); |
|
|
|
}) |
|
|
|
@ -90,7 +98,7 @@ public partial class ImageTests |
|
|
|
.Setup(x => x.DecodeAsync<Rgba32>(It.IsAny<DecoderOptions>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>())) |
|
|
|
.Callback<DecoderOptions, Stream, CancellationToken>((_, s, _) => |
|
|
|
{ |
|
|
|
using var ms = new MemoryStream(); |
|
|
|
using MemoryStream ms = new(); |
|
|
|
s.CopyTo(ms); |
|
|
|
this.DecodedData = ms.ToArray(); |
|
|
|
}) |
|
|
|
@ -100,7 +108,7 @@ public partial class ImageTests |
|
|
|
.Setup(x => x.DecodeAsync(It.IsAny<DecoderOptions>(), It.IsAny<Stream>(), It.IsAny<CancellationToken>())) |
|
|
|
.Callback<DecoderOptions, Stream, CancellationToken>((_, s, _) => |
|
|
|
{ |
|
|
|
using var ms = new MemoryStream(); |
|
|
|
using MemoryStream ms = new(); |
|
|
|
s.CopyTo(ms); |
|
|
|
this.DecodedData = ms.ToArray(); |
|
|
|
}) |
|
|
|
|