From 570aa8386d0c27d43d2a37160600cd312e223ef3 Mon Sep 17 00:00:00 2001
From: Torstein Stromme <torstein.stromme@uib.no>
Date: Sat, 11 Feb 2023 22:40:58 +0100
Subject: [PATCH] Added test case with different color arrangement

---
 .../no/uib/inf101/gridview/TestGridView.java  | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/test/java/no/uib/inf101/gridview/TestGridView.java b/src/test/java/no/uib/inf101/gridview/TestGridView.java
index 81abfc1..a3b3bf5 100644
--- a/src/test/java/no/uib/inf101/gridview/TestGridView.java
+++ b/src/test/java/no/uib/inf101/gridview/TestGridView.java
@@ -61,6 +61,28 @@ public class TestGridView {
     assertColorIsDrawnOnceAt(record, Color.GREEN, new Rectangle2D.Double(292.5, 200, 47.5, 40));
   }
 
+  @Test
+  public void drawCellsIllustratedSampleDifferentColors() {
+    // Sample case from assignment text
+    IColorGrid sampleGrid = TestCellPositionToPixelConverter.newGridFromString(String.join("\n",
+        "Y--R",
+        "----",
+        "G--B"
+    ));
+    Rectangle2D rect = new Rectangle2D.Double(30, 30, 340, 240);
+    double margin = 30;
+    RecordGraphics2D record = singleDrawCellsRun(sampleGrid, rect, margin);
+
+    // Check that the correct number of calls were made
+    assertEquals(12, record.getFillRecordShapes().size(),
+        "The drawCells method call draw 12 rectangles in the illustrated sample case");
+
+    assertColorIsDrawnOnceAt(record, Color.YELLOW, new Rectangle2D.Double(60, 60, 47.5, 40));
+    assertColorIsDrawnOnceAt(record, Color.RED, new Rectangle2D.Double(292.5, 60, 47.5, 40));
+    assertColorIsDrawnOnceAt(record, Color.GREEN, new Rectangle2D.Double(60, 200, 47.5, 40));
+    assertColorIsDrawnOnceAt(record, Color.BLUE, new Rectangle2D.Double(292.5, 200, 47.5, 40));
+  }
+
   @Test
   public void drawCellsIllustratedSampleTweak() {
     // Sample case from assignment text
-- 
GitLab