Browse Source

Fix dodgy constructor on FillPair and add tests

tznind 1 year ago
parent
commit
afc0bf02c5
2 changed files with 33 additions and 1 deletions
  1. 1 1
      Terminal.Gui/Drawing/FillPair.cs
  2. 32 0
      UnitTests/Drawing/FillPairTests.cs

+ 1 - 1
Terminal.Gui/Drawing/FillPair.cs

@@ -16,7 +16,7 @@ public class FillPair
     /// </summary>
     /// <param name="fore"></param>
     /// <param name="back"></param>
-    public FillPair (GradientFill fore, SolidFill back)
+    public FillPair (IFill fore, IFill back)
     {
         Foreground = fore;
         Background = back;

+ 32 - 0
UnitTests/Drawing/FillPairTests.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Terminal.Gui.Drawing;
+
+namespace Terminal.Gui.DrawingTests;
+
+public class FillPairTests
+{
+
+    [Fact]
+    public void GetAttribute_ReturnsCorrectColors ()
+    {
+        // Arrange
+        var foregroundColor = new Color (100, 150, 200);
+        var backgroundColor = new Color (50, 75, 100);
+        var foregroundFill = new SolidFill (foregroundColor);
+        var backgroundFill = new SolidFill (backgroundColor);
+
+        var fillPair = new FillPair (foregroundFill, backgroundFill);
+
+        // Act
+        var resultAttribute = fillPair.GetAttribute (new Point (0, 0));
+
+        // Assert
+        Assert.Equal (foregroundColor, resultAttribute.Foreground);
+        Assert.Equal (backgroundColor, resultAttribute.Background);
+    }
+}
+