コード例 #1
0
        public void TestPlaceCommand(string commandText, int xPos, int yPos, Orientation orientation)
        {
            _mockMovementProcessor.Place(xPos, yPos, orientation).Returns(info => new ActionOutcome(OutcomeStatus.Success));
            var outcome = _executor.ExecuteCommand(commandText);

            _mockMovementProcessor.Received().Place(xPos, yPos, orientation);
            outcome.Result.ShouldBe(OutcomeStatus.Success);
        }
コード例 #2
0
ファイル: PlaceCommand.cs プロジェクト: Argent78/LibToyBot
        private void ProcessCommand(string[] cmdTokens)
        {
            // if we don't have exactly 2 command tokens, then the command input was invalid
            if (cmdTokens.Length != 2)
            {
                throw new Exception();
            }

            // get the first token. If should be the PLACE command
            // the next token will be the X,Y,DIRECTION segment
            var positionTokens = cmdTokens[1].Split(',');

            // if we don't have exactly 3 position tokens, then the command input was invalid
            if (positionTokens.Length != 3)
            {
                throw new Exception();
            }

            // we should now have 3 tokens of X Y DIRECTION
            var xPosition   = int.Parse(positionTokens[0]);
            var yPosition   = int.Parse(positionTokens[1]);
            var orientation = Enum.Parse <Orientation>(positionTokens[2]);

            var outcome = _movementProcessor.Place(xPosition, yPosition, orientation);

            _callStack.Push(new Call(this, outcome));
        }
コード例 #3
0
        public void TestOutOfBoundsPlaceCommand(int xPos, int yPos, Orientation orientation)
        {
            var outcome = _movementProcessor.Place(xPos, yPos, orientation);

            outcome.Result.ShouldBe(OutcomeStatus.Fail);
        }