Browse Source

Add missing unit tests

af/merge-core
JimBobSquarePants 9 years ago
parent
commit
e53618c1f7
  1. 42
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

42
tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

@ -9,6 +9,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using System;
public class DrawImageTest : FileTestBase
{
private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32;
@ -42,5 +44,45 @@ namespace SixLabors.ImageSharp.Tests
image.DebugSave(provider, new { mode });
}
}
[Theory]
[WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, TestImages.Png.Splash)]
public void ImageShouldHandleNegativeLocation(TestImageProvider<Rgba32> provider, string backgroundPath)
{
using (Image<Rgba32> background = TestFile.Create(backgroundPath).CreateImage())
using (Image<Rgba32> overlay = provider.GetImage())
{
int xy = -25;
Rgba32 backgroundPixel = background[0, 0];
Rgba32 overlayPixel = overlay[Math.Abs(xy) + 1, Math.Abs(xy) + 1];
background.Mutate(x => x.DrawImage(overlay, PixelBlenderMode.Normal, 1F, new Size(overlay.Width, overlay.Height), new Point(xy, xy)));
Assert.Equal(default(Rgba32), backgroundPixel);
Assert.Equal(overlayPixel, background[0, 0]);
background.DebugSave(provider, new[] { "Negative" });
}
}
[Theory]
[WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, TestImages.Png.Splash)]
public void ImageShouldHandlePositiveLocation(TestImageProvider<Rgba32> provider, string backgroundPath)
{
using (Image<Rgba32> background = TestFile.Create(backgroundPath).CreateImage())
using (Image<Rgba32> overlay = provider.GetImage())
{
int xy = 25;
Rgba32 backgroundPixel = background[xy - 1, xy - 1];
Rgba32 overlayPixel = overlay[0, 0];
background.Mutate(x => x.DrawImage(overlay, PixelBlenderMode.Normal, 1F, new Size(overlay.Width, overlay.Height), new Point(xy, xy)));
Assert.Equal(default(Rgba32), backgroundPixel);
Assert.Equal(overlayPixel, background[xy, xy]);
background.DebugSave(provider, new[] { "Positive" });
}
}
}
}

Loading…
Cancel
Save