Skip to content

Commit

Permalink
Add more tests to LandGrabInSpaceTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
cizra committed Aug 27, 2024
1 parent cd81e9d commit 3f11ba5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions exercises/concept/land-grab-in-space/LandGrabInSpaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3f11ba5

Please sign in to comment.