@@ -7,6 +7,7 @@ using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using WhichPiece = Gameboard.ShogiUI.Sockets.ServiceModels.Types.WhichPiece;
|
||||
using WhichPerspective = Gameboard.ShogiUI.Sockets.ServiceModels.Types.WhichPerspective;
|
||||
using ShogiModel = Gameboard.ShogiUI.Sockets.Models.Shogi;
|
||||
|
||||
namespace Gameboard.ShogiUI.xUnitTests
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void InitializeBoardState()
|
||||
{
|
||||
// Act
|
||||
var board = new Shogi().Board;
|
||||
var board = new ShogiModel().Board;
|
||||
|
||||
// Assert
|
||||
board["A1"].WhichPiece.Should().Be(WhichPiece.Lance);
|
||||
@@ -204,7 +205,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P1 Pawn
|
||||
new Move("A3", "A4")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
shogi.Board["A3"].Should().BeNull();
|
||||
shogi.Board["A4"].WhichPiece.Should().Be(WhichPiece.Pawn);
|
||||
}
|
||||
@@ -222,7 +223,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P1 Bishop puts P2 in check
|
||||
new Move("B2", "G7"),
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
shogi.InCheck.Should().Be(WhichPerspective.Player2);
|
||||
|
||||
// Act - P2 is able to un-check theirself.
|
||||
@@ -239,7 +240,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_MoveFromEmptyPosition()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
shogi.Board["D5"].Should().BeNull();
|
||||
|
||||
// Act
|
||||
@@ -255,7 +256,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_MoveToCurrentPosition()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
|
||||
// Act - P1 "moves" pawn to the position it already exists at.
|
||||
var moveSuccess = shogi.Move(new Move("A3", "A3"));
|
||||
@@ -271,7 +272,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_MoveSet()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
|
||||
// Act - Move Lance illegally
|
||||
var moveSuccess = shogi.Move(new Move("A1", "D5"));
|
||||
@@ -288,7 +289,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_Ownership()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
shogi.WhoseTurn.Should().Be(WhichPerspective.Player1);
|
||||
shogi.Board["A7"].Owner.Should().Be(WhichPerspective.Player2);
|
||||
|
||||
@@ -305,7 +306,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_MoveThroughAllies()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
|
||||
// Act - Move P1 Lance through P1 Pawn.
|
||||
var moveSuccess = shogi.Move(new Move("A1", "A5"));
|
||||
@@ -321,7 +322,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
public void PreventInvalidMoves_CaptureAlly()
|
||||
{
|
||||
// Arrange
|
||||
var shogi = new Shogi();
|
||||
var shogi = new ShogiModel();
|
||||
|
||||
// Act - P1 Knight tries to capture P1 Pawn.
|
||||
var moveSuccess = shogi.Move(new Move("B1", "C3"));
|
||||
@@ -347,7 +348,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P1 Bishop puts P2 in check
|
||||
new Move("B2", "G7")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
shogi.InCheck.Should().Be(WhichPerspective.Player2);
|
||||
|
||||
// Act - P2 moves Lance while in check.
|
||||
@@ -387,7 +388,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P2 Pawn captures P1 Pawn
|
||||
new Move("I4", "I3")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
shogi.Player1Hand.Count.Should().Be(4);
|
||||
shogi.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Knight);
|
||||
shogi.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Lance);
|
||||
@@ -448,7 +449,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P1 drop Bishop, place P2 in check
|
||||
new Move(WhichPiece.Bishop, "G7")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
shogi.InCheck.Should().Be(WhichPerspective.Player2);
|
||||
shogi.Player2Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
|
||||
shogi.Board["E5"].Should().BeNull();
|
||||
@@ -478,7 +479,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P2 Pawn
|
||||
new Move("G6", "G5")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
using (new AssertionScope())
|
||||
{
|
||||
shogi.Player1Hand.Should().ContainSingle(_ => _.WhichPiece == WhichPiece.Bishop);
|
||||
@@ -512,7 +513,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P2 Pawn
|
||||
new Move("G7", "G6"),
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
|
||||
// Act - P1 Bishop, check
|
||||
shogi.Move(new Move("B2", "G7"));
|
||||
@@ -532,7 +533,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P2 Pawn
|
||||
new Move("G7", "G6" )
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
|
||||
// Act - P1 moves across promote threshold.
|
||||
var moveSuccess = shogi.Move(new Move("B2", "G7", true));
|
||||
@@ -576,7 +577,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
// P2 King retreat
|
||||
new Move("E8", "E9"),
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
output.WriteLine(shogi.PrintStateAsAscii());
|
||||
|
||||
// Act - P1 Pawn wins by checkmate.
|
||||
@@ -598,7 +599,7 @@ namespace Gameboard.ShogiUI.xUnitTests
|
||||
new Move("C3", "C4"),
|
||||
new Move("G7", "G6")
|
||||
};
|
||||
var shogi = new Shogi(moves);
|
||||
var shogi = new ShogiModel(moves);
|
||||
|
||||
// Act - P1 Bishop captures P2 Bishop
|
||||
var moveSuccess = shogi.Move(new Move("B2", "H8"));
|
||||
|
||||
Reference in New Issue
Block a user