Ejemplo n.º 1
0
        public void ExecutePlaceCommandSuccessfulTest()
        {
            var subject = new RoboControlCenter(_roboman, _commandResult);

            string[] commandStringInput = { AppTestConstants.PlaceCommandString, AppTestConstants.ValidPlaceCommandStringArgument };

            var expectedActionResult = new MovementActionResult(MovementStatus.RobotPlacementSuccessful);

            _roboman.SetPositionOnBoard(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <FaceDirection>()).ReturnsForAnyArgs(expectedActionResult);

            _controlCenter.ExecuteCommand(commandStringInput);

            // Assert IRobot

            _roboman.DidNotReceive().Move();

            _roboman.DidNotReceive().Left();

            _roboman.DidNotReceive().Right();

            _roboman.DidNotReceive().ReportStatus();

            // Assert roboman is the same with given command string //

            _roboman.Received().SetPositionOnBoard(1, 1, FaceDirection.NORTH);

            // Assert ICommandResult was called with the proper actionResult

            _commandResult.Received().ProcessResult(expectedActionResult);
        }
Ejemplo n.º 2
0
        public void ExecuteInvalidPlaceYAxisCommandSuccessfulTest()
        {
            var subject = new RoboControlCenter(_roboman, _commandResult);

            string[] commandStringInput = { "place", "1,B,DOWNTOWN" };

            _controlCenter.ExecuteCommand(commandStringInput);

            // Assert IRobot

            _roboman.DidNotReceive().Move();

            _roboman.DidNotReceive().Left();

            _roboman.DidNotReceive().Right();

            _roboman.DidNotReceive().ReportStatus();

            // Assert roboman is the same with given command string //

            _roboman.DidNotReceive().SetPositionOnBoard(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <FaceDirection>());

            // Assert ICommandResult was called with the proper actionResult

            _commandResult.Received().ProcessResult(Arg.Is <MovementActionResult>(x => x.Status == MovementStatus.RobotPlaceInvalidCommandParsed));
        }
Ejemplo n.º 3
0
        public void ExecuteRightCommandSuccessfulTest()
        {
            var subject = new RoboControlCenter(_roboman, _commandResult);

            string[] commandStringInput = { AppTestConstants.RightCommandString };

            var expectedActionResult = new MovementActionResult(MovementStatus.TurnRightSuccessful);

            _roboman.Right().Returns(expectedActionResult);

            _controlCenter.ExecuteCommand(commandStringInput);

            // Assert IRobot

            _roboman.DidNotReceive().Move();

            _roboman.DidNotReceive().Left();

            _roboman.Received().Right();

            _roboman.DidNotReceive().ReportStatus();

            // Assert ICommandResult was called with the proper actionResult

            _commandResult.Received().ProcessResult(expectedActionResult);
        }