|
|
|
@ -10,7 +10,6 @@ namespace ImageSharp.Tests |
|
|
|
|
|
|
|
using ImageSharp.Formats; |
|
|
|
using ImageSharp.IO; |
|
|
|
using ImageSharp.PixelFormats; |
|
|
|
using Moq; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
@ -44,7 +43,8 @@ namespace ImageSharp.Tests |
|
|
|
|
|
|
|
this.localDecoder.Setup(x => x.Decode<Rgba32>(It.IsAny<Configuration>(), It.IsAny<Stream>())) |
|
|
|
|
|
|
|
.Callback<Configuration, Stream>((c, s) => { |
|
|
|
.Callback<Configuration, Stream>((c, s) => |
|
|
|
{ |
|
|
|
using (var ms = new MemoryStream()) |
|
|
|
{ |
|
|
|
s.CopyTo(ms); |
|
|
|
@ -76,7 +76,7 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromStream() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
@ -87,12 +87,11 @@ namespace ImageSharp.Tests |
|
|
|
public void LoadFromNoneSeekableStream() |
|
|
|
{ |
|
|
|
NoneSeekableStream stream = new NoneSeekableStream(this.DataStream); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(stream); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(stream); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, Configuration.Default); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -104,20 +103,18 @@ namespace ImageSharp.Tests |
|
|
|
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img); |
|
|
|
|
|
|
|
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, Configuration.Default); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void LoadFromStreamWithConfig() |
|
|
|
{ |
|
|
|
Stream stream = new MemoryStream(); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, stream)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -130,7 +127,6 @@ namespace ImageSharp.Tests |
|
|
|
Assert.Equal(this.returnImage, img); |
|
|
|
|
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, stream)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +134,7 @@ namespace ImageSharp.Tests |
|
|
|
public void LoadFromStreamWithDecoder() |
|
|
|
{ |
|
|
|
Stream stream = new MemoryStream(); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream)); |
|
|
|
@ -158,13 +154,11 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromBytes() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray()); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray()); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
|
|
|
|
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, Configuration.Default); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -182,7 +176,7 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromBytesWithConfig() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray()); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray()); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
@ -207,7 +201,7 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromBytesWithDecoder() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, It.IsAny<Stream>())); |
|
|
|
@ -228,13 +222,11 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromFile() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
|
|
|
|
TestFormat.GlobalTestFormat.VerifyDecodeCall(this.Marker, Configuration.Default); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -251,12 +243,11 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromFileWithConfig() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
|
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, this.DataStream)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -273,7 +264,7 @@ namespace ImageSharp.Tests |
|
|
|
[Fact] |
|
|
|
public void LoadFromFileWithDecoder() |
|
|
|
{ |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object); |
|
|
|
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object); |
|
|
|
|
|
|
|
Assert.NotNull(img); |
|
|
|
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream)); |
|
|
|
@ -305,7 +296,6 @@ namespace ImageSharp.Tests |
|
|
|
|
|
|
|
Assert.Equal(Rgba32.White, px[1, 0]); |
|
|
|
Assert.Equal(Rgba32.Black, px[1, 1]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -327,7 +317,31 @@ namespace ImageSharp.Tests |
|
|
|
|
|
|
|
Assert.Equal(Rgba32.White, px[1, 0]); |
|
|
|
Assert.Equal(Rgba32.Black, px[1, 1]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TestThatTwoImagesAreEqual() |
|
|
|
{ |
|
|
|
var image1Provider = TestImageProvider<Rgba32>.File(TestImages.Png.VimImage1); |
|
|
|
var image2Provider = TestImageProvider<Rgba32>.File(TestImages.Png.VimImage2); |
|
|
|
|
|
|
|
using (Image<Rgba32> img1 = image1Provider.GetImage()) |
|
|
|
using (Image<Rgba32> img2 = image2Provider.GetImage()) |
|
|
|
{ |
|
|
|
Assert.Equal(img1.Width, img2.Width); |
|
|
|
Assert.Equal(img1.Height, img2.Height); |
|
|
|
|
|
|
|
for (int y = 0; y < img1.Height; y++) |
|
|
|
{ |
|
|
|
for (int x = 0; x < img1.Width; x++) |
|
|
|
{ |
|
|
|
Rgba32 pixel1 = img1[x, y]; |
|
|
|
Rgba32 pixel2 = img2[x, y]; |
|
|
|
|
|
|
|
Assert.Equal(pixel1, pixel2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|