Skip to content

Commit

Permalink
Adds a test for multiple adjacent feature matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Richardson committed Feb 14, 2018
1 parent adb80e1 commit fcf8d48
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sharpasonne.Tests/PlacementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
53 changes: 51 additions & 2 deletions Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Sharpasonne.Rules;
using Xunit;
using System.Collections.Immutable;
using System.Diagnostics;
using Optional.Unsafe;

namespace Sharpasonne.Tests.Rules
Expand Down Expand Up @@ -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<AdjacentFeaturesMatchRule>(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<AdjacentFeaturesMatchRule>(engine, centreAction);
}
}
}

0 comments on commit fcf8d48

Please sign in to comment.