Execute() public method

public Execute ( ) : void
return void
コード例 #1
0
        public void StartNewGame_ValidGameSettings_GameCreated()
        {
            // arrange
            StartGameCommand testStartCommand = new StartGameCommand(_gameCreatorMock.Object, _manipulatorMock.Object, _defaultSettings);

            // act
            testStartCommand.Execute();

            // assert
            _gameCreatorMock.Verify(c => c.CreateGame(_defaultSettings, _manipulatorMock.Object), Times.Once());
        }
コード例 #2
0
        public void StartGameCommandTest()
        {
            createContext();

            ICommand startGameCommand = new StartGameCommand(_context, EState.DECIDING, true);

            startGameCommand.Execute();

            Assert.IsNotNull(_context.Robot);
            Assert.IsTrue(_context.State is DecidingState);
        }
コード例 #3
0
        public void StartGameWithTwoCounterKing()
        {
            var game = new Game
            {
                State   = new LobbyState(),
                Players =
                {
                    new Player
                    {
                        User = new User
                        {
                            Id = 1
                        },
                        IsOwner = true,
                        Deck    = new Deck
                        {
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card
                                {
                                    Effect = GwintEffect.CounterKing
                                }
                            }
                        }
                    },
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card
                                {
                                    Effect = GwintEffect.CounterKing
                                }
                            }
                        }
                    }
                }
            };
            var command = new StartGameCommand
            {
                SenderUserId = 1
            };

            command.Execute(game);

            Assert.True(game.Players.All(p => !p.CanUseBattleKingCard));
        }
コード例 #4
0
        public void PlayerStartingPositionsAreLogged()
        {
            var player1 = new Player("Player 1");
            var player2 = new Player("Player 2");
            var game    = Game.CreateNewGame(10, 10, player1, player2);
            var log     = new JsonMessageLog();

            var command = new StartGameCommand();

            command.Execute(game, log);

            log.AssertMessageTypes(GameMessageType.NewGame, GameMessageType.PlayerAdded, GameMessageType.PlayerAdded);
        }
コード例 #5
0
        public void StartGame()
        {
            var game = new Game
            {
                State   = new LobbyState(),
                Players =
                {
                    new Player
                    {
                        User = new User
                        {
                            Id = 1
                        },
                        IsOwner = true,
                        Deck    = new Deck
                        {
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card()
                            }
                        }
                    },
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card()
                            }
                        }
                    }
                }
            };
            var command = new StartGameCommand
            {
                SenderUserId = 1
            };

            command.Execute(game);

            Assert.IsType(typeof(RedrawState), command.NextState);
            Assert.True(game.Players.All(p => p.CanUseBattleKingCard));
            Assert.NotNull(game.Players.SingleOrDefault(p => p.IsRoundStarter));
        }
コード例 #6
0
        public void StartGameWithScoiataelFaction()
        {
            var game = new Game
            {
                State   = new LobbyState(),
                Players =
                {
                    new Player
                    {
                        User = new User
                        {
                            Id = 1
                        },
                        IsOwner = true,
                        Deck    = new Deck
                        {
                            Faction        = GwintFaction.Scoiatael,
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card()
                            }
                        }
                    },
                    new Player
                    {
                        User = new User
                        {
                            Id = 2
                        },
                        Deck = new Deck
                        {
                            BattleKingCard = new DeckCard
                            {
                                Card = new Card()
                            }
                        }
                    }
                }
            };
            var command = new StartGameCommand
            {
                SenderUserId = 1
            };

            command.Execute(game);

            Assert.IsType(typeof(PickStartingPlayerState), command.NextState);
        }
コード例 #7
0
        public void TwoPlayersStartInOppositeCorners()
        {
            var player1 = new Player("Player 1");
            var player2 = new Player("Player 2");
            var game    = Game.CreateNewGame(10, 10, player1, player2);
            var log     = new JsonMessageLog();

            var command = new StartGameCommand();

            command.Execute(game, log);

            var pos1 = player1.Position;
            var pos2 = player2.Position;

            Assert.AreEqual(0, pos1.X);
            Assert.AreEqual(0, pos1.Y);

            Assert.AreEqual(9, pos2.X);
            Assert.AreEqual(9, pos2.Y);
        }
コード例 #8
0
        public void ParseCommand(int action)
        {
            switch (action)
            {
            case 1:
                ICommand startGameCommand = new StartGameCommand(this.gameService, this.userService,
                                                                 this.boardOutputService, this.tetrominoService, this.currentTetrominoService,
                                                                 this.boardService);
                startGameCommand.Execute();
                break;

            case 2:
                ICommand howToPlayCommand = new HowToPlayCommand(this.menuService);
                howToPlayCommand.Execute();
                break;

            case 3:
                ICommand showScoresCommand = new ShowScoresCommand(this.menuService, this.userService);
                showScoresCommand.Execute();
                break;

            case 4:
                ICommand showHighScoresCommand = new ShowHighScoresCommand(this.menuService, this.highScoreService);
                showHighScoresCommand.Execute();
                break;

            case 5:
                ICommand showCreditsCommand = new ShowCreditsCommand(this.menuService);
                showCreditsCommand.Execute();
                break;

            case 6:
                Environment.Exit(0);
                break;
            }
        }