Better fix

This commit is contained in:
2024-11-01 21:38:33 -05:00
parent d8432b98fe
commit 7258ac29a0
3 changed files with 47 additions and 28 deletions

View File

@@ -103,18 +103,19 @@ namespace UnitTests
// Arrange
var shogi = MockShogiBoard();
var board = shogi.BoardState;
var expectedPiece = board["A1"];
expectedPiece!.WhichPiece.Should().Be(WhichPiece.Lance);
var expectedPiece = board["D1"];
expectedPiece!.WhichPiece.Should().Be(WhichPiece.GoldGeneral);
// Act - Move Lance illegally
var moveResult = shogi.Move("A1", "D5", false);
// Act - Move General illegally
var moveResult = shogi.Move("D1", "D5", false);
// Assert
using (new AssertionScope())
{
moveResult.Should().NotBeNull();
moveResult.IsSuccess.Should().BeFalse(); board["A1"].Should().Be(expectedPiece);
board["A5"].Should().BeNull();
moveResult.IsSuccess.Should().BeFalse();
board["D1"].Should().Be(expectedPiece);
board["D5"].Should().BeNull();
board.Player1Hand.Should().BeEmpty();
board.Player2Hand.Should().BeEmpty();
}
@@ -292,19 +293,19 @@ namespace UnitTests
// Arrange
var shogi = MockShogiBoard();
// P1 Pawn
shogi.Move("C3", "C4", false);
shogi.Move("C3", "C4", false).IsSuccess.Should().BeTrue();
// P2 Pawn
shogi.Move("G7", "G6", false);
shogi.Move("G7", "G6", false).IsSuccess.Should().BeTrue();
// P1 Pawn, arbitrary move.
shogi.Move("A3", "A4", false);
shogi.Move("A3", "A4", false).IsSuccess.Should().BeTrue();
// P2 Bishop takes P1 Bishop
shogi.Move("H8", "B2", false);
shogi.Move("H8", "B2", false).IsSuccess.Should().BeTrue();
// P1 Silver takes P2 Bishop
shogi.Move("C1", "B2", false);
shogi.Move("C1", "B2", false).IsSuccess.Should().BeTrue();
// P2 Pawn, arbtrary move
shogi.Move("A7", "A6", false);
shogi.Move("A7", "A6", false).IsSuccess.Should().BeTrue();
// P1 drop Bishop, place P2 in check
shogi.Move(WhichPiece.Bishop, "G7");
shogi.Move(WhichPiece.Bishop, "G7").IsSuccess.Should().BeTrue();
shogi.BoardState.InCheck.Should().Be(WhichPlayer.Player2);
shogi.BoardState.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
shogi.BoardState["E5"].Should().BeNull();