Exemplo n.º 1
0
        public void StartNewGame_Should_Return_A_Guid()
        {
            GameService gameService = GameServiceFactory.Create();
            Guid        gameId      = gameService.StartNewGame("Carlos", "Marta");

            Assert.AreNotEqual(Guid.Empty, gameId);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        public App()
        {
            InitializeComponent();

            var          letterPairGeneratorFactory = new InternalLetterPairGeneratorFactory();
            var          timerServiceFactory        = new TimerFactory();
            IGameService gameService = new GameServiceFactory(letterPairGeneratorFactory, timerServiceFactory).Create();

            MainPage = new NavigationPage(new HomePage(gameService));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public CardGameController()
 {
     personCardGameService    = GameServiceFactory.Create <IPersonCardGameService>();
     spaceshipCardGameService = GameServiceFactory.Create <ISpaceshipCardGameService>();
 }
Exemplo n.º 12
0
 public void Setup()
 {
     _gameController = new GamesController(GameServiceFactory.Create(), null);
 }
Exemplo n.º 13
0
 public void Setup()
 {
     this.personCardGameService    = GameServiceFactory.Create <IPersonCardGameService>();
     this.spaceshipCardGameService = GameServiceFactory.Create <ISpaceshipCardGameService>();
 }