public void StartNewGame_Should_Return_A_Guid() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Carlos", "Marta"); Assert.AreNotEqual(Guid.Empty, gameId); }
public void Movement_On_GameOver_Should_Not_Be_Allowed() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Marta", "Carlos"); Game game = gameService.GetGame(gameId); gameService = GameServiceFactory.Create(game.WhitesPlayer.Id); MakeMoveResult makeMoveResult = gameService.MakeMove(gameId, Position.Create("E2"), Position.Create("E4")); Assert.IsTrue(makeMoveResult.Success); gameService = GameServiceFactory.Create(game.BlacksPlayer.Id); makeMoveResult = gameService.MakeMove(gameId, Position.Create("D7"), Position.Create("D5")); Assert.IsTrue(makeMoveResult.Success); gameService = GameServiceFactory.Create(game.WhitesPlayer.Id); makeMoveResult = gameService.MakeMove(gameId, Position.Create("F1"), Position.Create("B5")); Assert.IsTrue(makeMoveResult.Success); gameService = GameServiceFactory.Create(game.BlacksPlayer.Id); makeMoveResult = gameService.MakeMove(gameId, Position.Create("A7"), Position.Create("A6")); Assert.IsTrue(makeMoveResult.Success); gameService = GameServiceFactory.Create(game.WhitesPlayer.Id); makeMoveResult = gameService.MakeMove(gameId, Position.Create("B5"), Position.Create("E8")); Assert.IsTrue(makeMoveResult.Success); Assert.AreEqual(EventType.GameOver, makeMoveResult.TurnLog.TurnEvents.Last().EventType); Assert.IsTrue(gameService.GetGame(gameId).IsOver); }
public void CurrentPlayer_After_StartNewGame_Should_Return_A_Whites() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Carlos", "Marta"); Game game = gameService.GetGame(gameId); Assert.AreEqual(game.WhitesPlayer, game.CurrentTurnPlayer); }
public void Try_Movement_Before_Game_Can_Start_Should_Not_Be_Allowed() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.PrepareGame(); MakeMoveResult makeMoveResult = gameService.MakeMove(gameId, Position.Create("E2"), Position.Create("E4")); Assert.IsFalse(makeMoveResult.Success); }
public App() { InitializeComponent(); var letterPairGeneratorFactory = new InternalLetterPairGeneratorFactory(); var timerServiceFactory = new TimerFactory(); IGameService gameService = new GameServiceFactory(letterPairGeneratorFactory, timerServiceFactory).Create(); MainPage = new NavigationPage(new HomePage(gameService)); }
public void MakeMove_From_Incorrect_Turn_Should_Return_Fail() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Carlos", "Marta"); Game game = gameService.GetGame(gameId); MakeMoveResult makeMoveResult = gameService.MakeMove(gameId, Position.Create("A7"), Position.Create("A6")); Assert.IsFalse(makeMoveResult.Success); }
public void MakeMove_From_Empty_Square_Should_Return_Fail() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Carlos", "Marta"); Game game = gameService.GetGame(gameId); MakeMoveResult makeMoveResult = gameService.MakeMove(gameId, Position.Create("A3"), Position.Create("A4")); Assert.IsFalse(makeMoveResult.Success); Assert.IsFalse(game.Board.GetSquare("A2").IsEmpty); Assert.IsTrue(game.Board.GetSquare("A3").IsEmpty); }
public GameActionRelay( GameServiceFactory gameServiceFactory, ConnectionManager connectionManager, IPushNotificationService pushNotificationService, IGameManager gameManager, PlayerManager playerManager, IAIManager AIManager) { _finalBoardRequests = new List <Guid>(); _gameServiceFactory = gameServiceFactory; _connectionManager = connectionManager; _pushNotificationService = pushNotificationService; _gameManager = gameManager; _playerManager = playerManager; _AIManager = AIManager; }
public void MakeMove_Should_Change_Piece_Position() { GameService gameService = GameServiceFactory.Create(); Guid gameId = gameService.StartNewGame("Carlos", "Marta"); Game game = gameService.GetGame(gameId); gameService = GameServiceFactory.Create(game.WhitesPlayer.Id); Assert.IsFalse(game.Board.GetSquare("A2").IsEmpty); Assert.IsTrue(game.Board.GetSquare("A4").IsEmpty); MakeMoveResult makeMoveResult = gameService.MakeMove(gameId, Position.Create("A2"), Position.Create("A4")); Assert.IsTrue(makeMoveResult.Success); Assert.IsTrue(game.Board.GetSquare("A2").IsEmpty); Assert.IsFalse(game.Board.GetSquare("A4").IsEmpty); }
public async Task Move_Action_Should_Return_List_Of_Events() { GamesController gameController = new GamesController(GameServiceFactory.Create(), null); ActionResult <Guid> responseStart = gameController.Start(new StartGameArguments { Player1 = "Carlos", Player2 = "Marta" }); Guid whitesPlayerId = gameController.GetGameState(responseStart.Value).Value.WhitesPlayer.Id; gameController = new GamesController(GameServiceFactory.Create(whitesPlayerId), null); ActionResult <TurnLog> response = await gameController.Move(responseStart.Value, new MoveArguments { Origin = "C2", Destination = "C4" }); Assert.IsNotNull(response.Value); Assert.AreNotEqual(0, response.Value.TurnEvents.Count); }
public CardGameController() { personCardGameService = GameServiceFactory.Create <IPersonCardGameService>(); spaceshipCardGameService = GameServiceFactory.Create <ISpaceshipCardGameService>(); }
public void Setup() { _gameController = new GamesController(GameServiceFactory.Create(), null); }
public void Setup() { this.personCardGameService = GameServiceFactory.Create <IPersonCardGameService>(); this.spaceshipCardGameService = GameServiceFactory.Create <ISpaceshipCardGameService>(); }