Browse Source

Fix note comment and add tests for SolidFill class

tznind 1 year ago
parent
commit
8a56586fec
2 changed files with 41 additions and 1 deletions
  1. 1 1
      UnitTests/Drawing/GradientTests.cs
  2. 40 0
      UnitTests/Drawing/SolidFillTests.cs

+ 1 - 1
UnitTests/Drawing/GradientTests.cs

@@ -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));

+ 40 - 0
UnitTests/Drawing/SolidFillTests.cs

@@ -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);
+    }
+}