From 3f11ba5248a6bc93a17c40fbab9de5919f33dabf Mon Sep 17 00:00:00 2001 From: Elmo Todurov Date: Tue, 27 Aug 2024 23:56:06 +0300 Subject: [PATCH] Add more tests to LandGrabInSpaceTests.cs See discussion at https://forum.exercism.org/t/land-grab-in-space-has-insufficient-test-coverage-for-the-plot-with-longest-side/9615 --- .../LandGrabInSpaceTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs b/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs index 5497b82199..0611589336 100644 --- a/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs +++ b/exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs @@ -59,6 +59,32 @@ public void GetLongestSide() Assert.Equal(longer, ch.GetClaimWithLongestSide()); } + [Fact] + [Task(4)] + public void GetLongestSideReverseInsertionOrder() + { + var ch = new ClaimsHandler(); + var longer = CreatePlot(new Coord(10, 1), new Coord(20, 1), new Coord(10, 2), new Coord(20, 2)); + var shorter = CreatePlot(new Coord(1, 1), new Coord(2, 1), new Coord(1, 2), new Coord(2, 2)); + ch.StakeClaim(shorter); + ch.StakeClaim(longer); + Assert.Equal(longer, ch.GetClaimWithLongestSide()); + } + + [Fact] + [Task(4)] + public void GetLongestSideDiagonal1() + { + var ch = new ClaimsHandler(); + // Bottom left, bottom right, top left, top right. The longest side is 10, diagonal is >14 + var shorter = CreatePlot(new Coord(0, 0), new Coord(0, 10), new Coord(10, 0), new Coord(10, 10)); + // Bottom left, top left, top right, bottom right, longest side 11 + var longer = CreatePlot(new Coord(0, 0), new Coord(11, 0), new Coord(11, 11), new Coord(0, 11)); + ch.StakeClaim(shorter); + ch.StakeClaim(longer); + Assert.Equal(longer, ch.GetClaimWithLongestSide()); + } + private Plot CreatePlot(Coord coord1, Coord coord2, Coord coord3, Coord coord4) { Type plotType = typeof(Plot);