Skip to content

Commit

Permalink
Removes parameterless constructor from Engine and fixes test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Richardson committed Feb 14, 2018
1 parent cfbeb80 commit 028d7d7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
13 changes: 8 additions & 5 deletions Sharpasonne.Tests/Rules/AdjacentFeaturesMatchRuleTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Sharpasonne.GameActions;
using Sharpasonne.GameActions;
using Sharpasonne.Models;
using Sharpasonne.Models.Features;
using Sharpasonne.Rules;
using Xunit;
using System.Collections.Immutable;
using System.Diagnostics;
using Moq;
using Optional.Unsafe;

namespace Sharpasonne.Tests.Rules
Expand All @@ -16,7 +14,12 @@ public class AdjacentFeaturesMatchRuleTest : UnitTest<PlaceTileGameAction>
[Fact]
public void Given_Empty_Then_True()
{
AssertTrue<AdjacentFeaturesMatchRule>(new Engine(), MakePlaceTile(0, 0));
var mockEngine = new Mock<IEngine>();
mockEngine
.Setup(e => e.Board)
.Returns(new Board());

AssertTrue<AdjacentFeaturesMatchRule>(mockEngine.Object, MakePlaceTile(0, 0));
}

[Fact]
Expand Down
14 changes: 7 additions & 7 deletions Sharpasonne.Tests/Rules/HasAdjacentTileRuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Sharpasonne.GameActions;
using Sharpasonne.GameActions;
using Sharpasonne.Rules;
using Xunit;
using Moq;
using Optional.Unsafe;
using Sharpasonne.Models;
using Sharpasonne.Models.Features;

namespace Sharpasonne.Tests.Rules
{
Expand All @@ -16,7 +11,12 @@ public class HasAdjacentTileRuleTests : UnitTest<PlaceTileGameAction>
[Fact]
public void Given_BoardIsEmpty_When_PlacingATile_Then_Validates()
{
AssertTrue<HasAdjacentTileRule>(new Engine(), MakePlaceTile(0, 0));
var mockEngine = new Mock<IEngine>();
mockEngine
.Setup(e => e.Board)
.Returns(new Board());

AssertTrue<HasAdjacentTileRule>(mockEngine.Object, MakePlaceTile(0, 0));
}

[Fact]
Expand Down
8 changes: 7 additions & 1 deletion Sharpasonne.Tests/Rules/SpaceIsEmptyRuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Moq;
using Sharpasonne.GameActions;
using Sharpasonne.Rules;
using Xunit;
Expand All @@ -11,7 +12,12 @@ public class SpaceIsEmptyRuleTests : UnitTest<PlaceTileGameAction>
[Fact]
public void When_TileIsEmpty_Then_True()
{
AssertTrue<SpaceIsEmptyRule>(new Engine(), MakePlaceTile(0, 0));
var mockEngine = new Mock<IEngine>();
mockEngine
.Setup(e => e.Board)
.Returns(new Board());

AssertTrue<SpaceIsEmptyRule>(mockEngine.Object, MakePlaceTile(0, 0));
}

[Fact]
Expand Down
8 changes: 7 additions & 1 deletion Sharpasonne.Tests/Rules/UniqueTileInstanceRuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Moq;
using Sharpasonne.GameActions;
using Sharpasonne.Models;
using Sharpasonne.Rules;
Expand All @@ -12,7 +13,12 @@ public class UniqueTileInstanceRuleTests : UnitTest<PlaceTileGameAction>
[Fact]
public void When_BoardIsEmpty_Then_True()
{
AssertTrue<UniqueTileInstanceRule>(new Engine(), MakePlaceTile(0, 0));
var mockEngine = new Mock<IEngine>();
mockEngine
.Setup(e => e.Board)
.Returns(new Board());

AssertTrue<UniqueTileInstanceRule>(mockEngine.Object, MakePlaceTile(0, 0));
}

[Fact]
Expand Down
4 changes: 0 additions & 4 deletions Sharpasonne/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ public class Engine : IEngine
public IImmutableDictionary<Type, IImmutableList<IRule<IGameAction>>> Rules { get; }
= ImmutableDictionary<Type, IImmutableList<IRule<IGameAction>>>.Empty;

public Engine()
{
}

/// <summary>
///
/// </summary>
Expand Down

0 comments on commit 028d7d7

Please sign in to comment.