Fix note comment and add tests for SolidFill class

This commit is contained in:
tznind
2024-07-07 21:30:31 +01:00
parent 52401229e2
commit 8a56586fec
2 changed files with 41 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ public class GradientTests
var g = new Gradient (stops, steps, loop: false);
// Note that
// Note that maxRow and maxCol are inclusive so this results in 1x1 area i.e. a single cell.
var c = Assert.Single (g.BuildCoordinateColorMapping (0, 0, direction));
Assert.Equal (c.Key, new Point(0,0));
Assert.Equal (c.Value, new Color (0, 0, 255));

View File

@@ -0,0 +1,40 @@

using Terminal.Gui.Drawing;
namespace Terminal.Gui.DrawingTests;
public class SolidFillTests
{
[Fact]
public void GetColor_ReturnsCorrectColor ()
{
// Arrange
var expectedColor = new Color (100, 150, 200);
var solidFill = new SolidFill (expectedColor);
// Act
var resultColor = solidFill.GetColor (new Point (0, 0));
// Assert
Assert.Equal (expectedColor, resultColor);
}
[Theory]
[InlineData (0, 0)]
[InlineData (1, 1)]
[InlineData (-1, -1)]
[InlineData (100, 100)]
[InlineData (-100, -100)]
public void GetColor_ReturnsSameColorForDifferentPoints (int x, int y)
{
// Arrange
var expectedColor = new Color (50, 100, 150);
var solidFill = new SolidFill (expectedColor);
// Act
var resultColor = solidFill.GetColor (new Point (x, y));
// Assert
Assert.Equal (expectedColor, resultColor);
}
}