Files
Shogi/Shogi.Domain.UnitTests/StandardRulesShould.cs
2021-12-29 16:27:43 -06:00

32 lines
788 B
C#

using FluentAssertions;
using FluentAssertions.Execution;
using Xunit;
namespace Shogi.Domain.UnitTests
{
public class StandardRulesShould
{
[Fact]
public void AllowValidMoves_AfterCheck()
{
// Arrange
var board = new ShogiBoardState();
var rules = new StandardRules(board);
rules.Move("C3", "C4"); // P1 Pawn
rules.Move("G7", "G6"); // P2 Pawn
rules.Move("B2", "G7"); // P1 Bishop puts P2 in check
board.InCheck.Should().Be(WhichPlayer.Player2);
// Act - P2 is able to un-check theirself.
/// P2 King moves out of check
var moveSuccess = rules.Move("E9", "E8");
// Assert
using var _ = new AssertionScope();
moveSuccess.Success.Should().BeTrue();
moveSuccess.Reason.Should().BeEmpty();
board.InCheck.Should().BeNull();
}
}
}