|
@@ -1,4 +1,5 @@
|
|
|
-using ChunkyImageLib.Operations;
|
|
|
+using ChunkyImageLib;
|
|
|
+using ChunkyImageLib.Operations;
|
|
|
using SkiaSharp;
|
|
|
using System.Collections.Generic;
|
|
|
using Xunit;
|
|
@@ -7,16 +8,17 @@ namespace ChunkyImageLibTest
|
|
|
{
|
|
|
public class RectangleOperationTests
|
|
|
{
|
|
|
+ const int chunkSize = ChunkPool.ChunkSize;
|
|
|
// to keep expected rectangles aligned
|
|
|
#pragma warning disable format
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_SmallStrokeOnly_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (0, 0, 32, 32);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent);
|
|
|
+ var (x, y, w, h) = (0, 0, chunkSize, chunkSize);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent));
|
|
|
|
|
|
HashSet<(int, int)> expected = new() { (0, 0) };
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -24,11 +26,11 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_2by2StrokeOnly_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (-32, -32, 64, 64);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent);
|
|
|
+ var (x, y, w, h) = (-chunkSize, -chunkSize, chunkSize * 2, chunkSize * 2);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent));
|
|
|
|
|
|
HashSet<(int, int)> expected = new() { (-1, -1), (0, -1), (-1, 0), (0, 0) };
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -36,8 +38,8 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_3x3PositiveStrokeOnly_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (48, 48, 64, 64);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent);
|
|
|
+ var (x, y, w, h) = (chunkSize + chunkSize / 2, chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent));
|
|
|
|
|
|
HashSet<(int, int)> expected = new()
|
|
|
{
|
|
@@ -45,7 +47,7 @@ namespace ChunkyImageLibTest
|
|
|
(1, 2), (3, 2),
|
|
|
(1, 3), (2, 3), (3, 3),
|
|
|
};
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -53,8 +55,8 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_3x3NegativeStrokeOnly_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (-112, -112, 64, 64);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent);
|
|
|
+ var (x, y, w, h) = (-chunkSize * 3 + chunkSize / 2, -chunkSize * 3 + chunkSize / 2, chunkSize * 2, chunkSize * 2);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 1, SKColors.Black, SKColors.Transparent));
|
|
|
|
|
|
HashSet<(int, int)> expected = new()
|
|
|
{
|
|
@@ -62,7 +64,7 @@ namespace ChunkyImageLibTest
|
|
|
(-4, -3), (-2, -3),
|
|
|
(-4, -2), (-3, -2), (-2, -2),
|
|
|
};
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -70,8 +72,8 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_3x3PositiveFilled_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (48, 48, 64, 64);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 1, SKColors.Black, SKColors.White);
|
|
|
+ var (x, y, w, h) = (chunkSize + chunkSize / 2, chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 1, SKColors.Black, SKColors.White));
|
|
|
|
|
|
HashSet<(int, int)> expected = new()
|
|
|
{
|
|
@@ -79,7 +81,7 @@ namespace ChunkyImageLibTest
|
|
|
(1, 2), (2, 2), (3, 2),
|
|
|
(1, 3), (2, 3), (3, 3),
|
|
|
};
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -87,8 +89,8 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_ThickPositiveStroke_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (16, 16, 128, 128);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 32, SKColors.Black, SKColors.Transparent);
|
|
|
+ var (x, y, w, h) = (chunkSize / 2, chunkSize / 2, chunkSize * 4, chunkSize * 4);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 32, SKColors.Black, SKColors.Transparent));
|
|
|
|
|
|
HashSet<(int, int)> expected = new()
|
|
|
{
|
|
@@ -98,7 +100,7 @@ namespace ChunkyImageLibTest
|
|
|
(0, 3), (1, 3), (2, 3), (3, 3), (4, 3),
|
|
|
(0, 4), (1, 4), (2, 4), (3, 4), (4, 4),
|
|
|
};
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|
|
@@ -106,11 +108,11 @@ namespace ChunkyImageLibTest
|
|
|
[Fact]
|
|
|
public void FindAffectedChunks_SmallButThick_FindsCorrectChunks()
|
|
|
{
|
|
|
- var (x, y, w, h) = (16, 16, 1, 1);
|
|
|
- RectangleOperation operation = new(x, y, w, h, 256, SKColors.Black, SKColors.White);
|
|
|
+ var (x, y, w, h) = (chunkSize / 2, chunkSize / 2, 1, 1);
|
|
|
+ RectangleOperation operation = new(new(x, y, w, h, 256, SKColors.Black, SKColors.White));
|
|
|
|
|
|
HashSet<(int, int)> expected = new() { (0, 0) };
|
|
|
- var actual = operation.FindAffectedChunks(32);
|
|
|
+ var actual = operation.FindAffectedChunks();
|
|
|
|
|
|
Assert.Equal(expected, actual);
|
|
|
}
|