42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Minint.Core.Models;
|
|
using Minint.Core.Services;
|
|
using Minint.Core.Services.Impl;
|
|
|
|
namespace Minint.Tests;
|
|
|
|
public class PatternGeneratorTests
|
|
{
|
|
private readonly PatternGenerator _gen = new();
|
|
|
|
[Theory]
|
|
[InlineData(PatternType.Checkerboard)]
|
|
[InlineData(PatternType.HorizontalGradient)]
|
|
[InlineData(PatternType.VerticalGradient)]
|
|
[InlineData(PatternType.HorizontalStripes)]
|
|
[InlineData(PatternType.VerticalStripes)]
|
|
[InlineData(PatternType.ConcentricCircles)]
|
|
[InlineData(PatternType.Tile)]
|
|
public void Generate_AllTypes_ProducesValidDocument(PatternType type)
|
|
{
|
|
var colors = new[] { new RgbaColor(255, 0, 0, 255), new RgbaColor(0, 0, 255, 255) };
|
|
var doc = _gen.Generate(type, 16, 16, colors, 4, 4);
|
|
|
|
Assert.Equal($"Pattern ({type})", doc.Name);
|
|
Assert.Single(doc.Layers);
|
|
Assert.Equal(256, doc.Layers[0].Pixels.Length);
|
|
Assert.True(doc.Palette.Count >= 2);
|
|
}
|
|
|
|
[Fact]
|
|
public void Generate_Checkerboard_AlternatesColors()
|
|
{
|
|
var colors = new[] { new RgbaColor(255, 0, 0, 255), new RgbaColor(0, 255, 0, 255) };
|
|
var doc = _gen.Generate(PatternType.Checkerboard, 4, 4, colors, 2);
|
|
|
|
var layer = doc.Layers[0];
|
|
int topLeft = layer.Pixels[0];
|
|
int topRight = layer.Pixels[2]; // cellSize=2, so (2,0) is next cell
|
|
Assert.NotEqual(topLeft, topRight);
|
|
}
|
|
}
|