Turn on remaining shogi domain tests.

This commit is contained in:
2023-02-02 19:45:02 -06:00
parent 09b52eddff
commit dbdaaf8b30

View File

@@ -216,7 +216,6 @@ namespace Shogi.Domain.UnitTests
} }
[Fact] [Fact]
// TODO: Consider nesting classes to share this setup in a constructor but have act and assert as separate facts.
public void PreventInvalidDrops_MoveSet() public void PreventInvalidDrops_MoveSet()
{ {
// Arrange // Arrange
@@ -281,79 +280,72 @@ namespace Shogi.Domain.UnitTests
// // TODO // // TODO
} }
//[Fact] [Fact]
//public void PreventInvalidDrop_Check() public void PreventInvalidDrop_Check()
//{ {
// // Arrange // Arrange
// var moves = new[] var shogi = MockShogiBoard();
// { // P1 Pawn
// // P1 Pawn shogi.Move("C3", "C4", false);
// new Move("C3", "C4"), // P2 Pawn
// // P2 Pawn shogi.Move("G7", "G6", false);
// new Move("G7", "G6"), // P1 Pawn, arbitrary move.
// // P1 Pawn, arbitrary move. shogi.Move("A3", "A4", false);
// new Move("A3", "A4"), // P2 Bishop takes P1 Bishop
// // P2 Bishop takes P1 Bishop shogi.Move("H8", "B2", false);
// new Move("H8", "B2"), // P1 Silver takes P2 Bishop
// // P1 Silver takes P2 Bishop shogi.Move("C1", "B2", false);
// new Move("C1", "B2"), // P2 Pawn, arbtrary move
// // P2 Pawn, arbtrary move shogi.Move("A7", "A6", false);
// new Move("A7", "A6"), // P1 drop Bishop, place P2 in check
// // P1 drop Bishop, place P2 in check shogi.Move(WhichPiece.Bishop, "G7");
// new Move(WhichPiece.Bishop, "G7")
// };
// var shogi = new Shogi(moves);
// shogi.InCheck.Should().Be(WhichPlayer.Player2);
// shogi.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
// board["E5"].Should().BeNull();
// // Act - P2 places a Bishop while in check. shogi.BoardState.InCheck.Should().Be(WhichPlayer.Player2);
// var dropSuccess = shogi.Move(new Move(WhichPiece.Bishop, "E5")); shogi.BoardState.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
shogi.BoardState["E5"].Should().BeNull();
// // Assert // Act - P2 places a Bishop while in check.
// dropSuccess.Should().BeFalse(); shogi.Move(WhichPiece.Bishop, "E5");
// board["E5"].Should().BeNull();
// shogi.InCheck.Should().Be(WhichPlayer.Player2);
// shogi.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
//}
//[Fact] // Assert
//public void PreventInvalidDrop_Capture() shogi.BoardState["E5"].Should().BeNull();
//{ shogi.BoardState.InCheck.Should().Be(WhichPlayer.Player2);
// // Arrange shogi.BoardState.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
// var moves = new[] }
// {
// // P1 Pawn
// new Move("C3", "C4"),
// // P2 Pawn
// new Move("G7", "G6"),
// // P1 Bishop capture P2 Bishop
// new Move("B2", "H8"),
// // P2 Pawn
// new Move("G6", "G5")
// };
// var shogi = new Shogi(moves);
// using (new AssertionScope())
// {
// shogi.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
// board["I9"].Should().NotBeNull();
// board["I9"].WhichPiece.Should().Be(WhichPiece.Lance);
// board["I9"].Owner.Should().Be(WhichPlayer.Player2);
// }
// // Act - P1 tries to place a piece where an opponent's piece resides. [Fact]
// var dropSuccess = shogi.Move(new Move(WhichPiece.Bishop, "I9")); public void PreventInvalidDrop_Capture()
{
// Arrange
var shogi = MockShogiBoard();
// P1 Pawn
shogi.Move("C3", "C4", false);
// P2 Pawn
shogi.Move("G7", "G6", false);
// P1 Bishop capture P2 Bishop
shogi.Move("B2", "H8", false);
// P2 Pawn
shogi.Move("G6", "G5", false);
using (new AssertionScope())
{
shogi.BoardState.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
shogi.BoardState["I9"].Should().NotBeNull();
shogi.BoardState["I9"]!.WhichPiece.Should().Be(WhichPiece.Lance);
shogi.BoardState["I9"]!.Owner.Should().Be(WhichPlayer.Player2);
}
// // Assert // Act - P1 tries to place a piece where an opponent's piece resides.
// using (new AssertionScope()) shogi.Move(WhichPiece.Bishop, "I9");
// {
// dropSuccess.Should().BeFalse(); // Assert
// shogi.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop); using (new AssertionScope())
// board["I9"].Should().NotBeNull(); {
// board["I9"].WhichPiece.Should().Be(WhichPiece.Lance); shogi.BoardState.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
// board["I9"].Owner.Should().Be(WhichPlayer.Player2); shogi.BoardState["I9"].Should().NotBeNull();
// } shogi.BoardState["I9"]!.WhichPiece.Should().Be(WhichPiece.Lance);
//} shogi.BoardState["I9"]!.Owner.Should().Be(WhichPlayer.Player2);
}
}
[Fact] [Fact]
public void Check() public void Check()