public void Test() { TestPiece t = new TestPiece() { gameId = game.GameId, playerGuid = game.Guid }; Send(XmlMessageConverter.ToXml(t)); }
public void Should_ReturnFalseForCanMoveTo() { // setup var piece = new TestPiece(ChessPosition.D1, ChessColor.White); piece.GenerateMoves(null); // boardstate is not considered in test class // execute bool canMove = NotMovesNotCaptures.All(n => piece.CanMoveTo(n)); // verify Assert.IsFalse(canMove); }
public void Should_ReturnFalseForIsThreateningAt() { // setup var piece = new TestPiece(ChessPosition.D1, ChessColor.White); piece.GenerateThreatened(null, null); // boardstate is not considered in test class // execute bool isThreatening = NotMovesNotCaptures.All(n => piece.IsThreateningAt(n)); // verify Assert.IsFalse(isThreatening); }
public void Should_ReturnTrueForCanCaptureAt() { // setup var piece = new TestPiece(ChessPosition.D1, ChessColor.White); piece.GenerateCaptures(null, null); // boardstate is not considered in test class // execute bool canCapture = TestCaptures.All(c => piece.CanCaptureAt(c)); // verify Assert.IsTrue(canCapture); }
public void Should_CaptureAtLocation() { // setup const ChessPosition FIRST_POSITION = ChessPosition.A1; const ChessPosition SECOND_POSITION = ChessPosition.A3; var piece = new TestPiece(FIRST_POSITION, ChessColor.White); Assert.IsFalse(piece.HasMoved); Assert.AreEqual(FIRST_POSITION, piece.Location); // execute piece.CaptureAt(SECOND_POSITION); // verify Assert.IsTrue(piece.HasMoved); Assert.AreEqual(SECOND_POSITION, piece.Location); }
public async void HandleMessage(TestPiece message, Socket handler) { if (!ValidateMessage(message)) { return; } string resp = ""; await Task.Delay((int)GameMasterClient.Settings.ActionCosts.TestDelay); Wrapper.Player currentPlayer = Players.SingleOrDefault(p => p.Guid == message.playerGuid); if (currentPlayer == null) { return; } GameMasterClient.Logger.Log(message, currentPlayer); lock (BoardLock) { Wrapper.Piece piece = Pieces.SingleOrDefault( pc => pc.PlayerId == currentPlayer.Id); if (piece == null) // not carrying anything { ConsoleDebug.Warning("Not carrying a piece!"); piece = Pieces.FirstOrDefault(pc => pc.Location.Equals(currentPlayer.Location)); } if (piece == null) { ConsoleDebug.Warning("Not on a piece!"); //send empty piece collection resp = new DataMessageBuilder(currentPlayer.Id, endGame) .SetPieces(new Piece[0]) .GetXml(); } else { ConsoleDebug.Warning("On a piece!"); resp = new DataMessageBuilder(currentPlayer.Id, endGame) .AddPiece(piece.SchemaPiece) .GetXml(); } } GameMasterClient.Connection.SendFromClient(handler, resp); }