From fcf8d48342161b1352863c29c3542e89f9f15481 Mon Sep 17 00:00:00 2001 From: Lee Richardson Date: Wed, 14 Feb 2018 19:19:16 +0000 Subject: [PATCH] Adds a test for multiple adjacent feature matching --- Sharpasonne.Tests/PlacementTests.cs | 2 +- .../Rules/AdjacentFeaturesMatchRuleTest.cs | 53 ++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Sharpasonne.Tests/PlacementTests.cs b/Sharpasonne.Tests/PlacementTests.cs index 787933a..5037e39 100644 --- a/Sharpasonne.Tests/PlacementTests.cs +++ b/Sharpasonne.Tests/PlacementTests.cs @@ -70,7 +70,7 @@ public void Given_AnUnrotatedTile_When_GettingRightEdge_Then_ReturnsRightEdge() } [Fact] - public void Given_AnRightRotatedTile_When_GettingRightEdge_Then_ReturnsBottomEdge() + public void Given_ARightRotatedTile_When_GettingRightEdge_Then_ReturnsBottomEdge() { // Arrange var field = new Field(ImmutableHashSet.Create( diff --git a/Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs b/Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs index 7b259eb..e20e66a 100644 --- a/Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs +++ b/Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs @@ -6,6 +6,7 @@ using Sharpasonne.Rules; using Xunit; using System.Collections.Immutable; +using System.Diagnostics; using Optional.Unsafe; namespace Sharpasonne.Tests.Rules @@ -150,10 +151,58 @@ public void Given_OneRotatedNeighbour_When_FeaturesMatch_Then_True() var leftAction = MakePlaceTile(0, 0, leftTile, Orientation.Top); var rightAction = MakePlaceTile(1, 0, rightTile, Orientation.Left); - var board = MakeBoard(leftAction); - var engine = MockEngine(board); + var board = MakeBoard(leftAction); + var engine = MockEngine(board); AssertTrue(engine, rightAction); } + + [Fact] + public void Given_TwoRotatedNeighbours_When_FeaturesMatch_Then_True() + { + var topTile = new TileBuilder() + .CreateTile(new IFeature[] + { + new Field(ImmutableHashSet.Create( + Segment.RightTop, + Segment.Right, + Segment.RightBottom + )), + }) + .ValueOrFailure(); + + var centreTile = new TileBuilder() + .CreateTile(new[] + { + new Field(ImmutableHashSet.Create( + Segment.TopLeft, + Segment.Top, + Segment.TopRight, + Segment.BottomLeft, + Segment.Bottom, + Segment.BottomRight + )), + }) + .ValueOrFailure(); + + var bottomTile = new TileBuilder() + .CreateTile(new[] + { + new Field(ImmutableHashSet.Create( + Segment.RightTop, + Segment.Right, + Segment.RightBottom + )), + }) + .ValueOrFailure(); + + var topAction = MakePlaceTile(0, 1, topTile, Orientation.Right); + var centreAction = MakePlaceTile(0, 0, centreTile, Orientation.Bottom); + var bottomAction = MakePlaceTile(0, -1, bottomTile, Orientation.Left); + var board = MakeBoard(topAction, bottomAction); + var engine = MockEngine(board); + + AssertTrue(engine, centreAction); + } } } \ No newline at end of file