コード例 #1
0
        private Result <Exception, int> ProcessHeadAlign(HeadAlignCommand command, RobotAgreggate robot)
        {
            Result <Exception, Align> moveCallback;

            switch (command.HeadMove.ToLower())
            {
            case "top":
                moveCallback = robot.MoveHeadForUp();
                break;

            case "down":
                moveCallback = robot.MoveHeadToBelow();
                break;

            default:
                return(new BussinessException(ErrorCodes.BadRequest, "Comando inválido."));
            }

            if (moveCallback.IsSuccess)
            {
                return(PersistRobotState(robot, (int)moveCallback.Success));
            }

            return(moveCallback.Failure);
        }
コード例 #2
0
        public void MoveHeadForUpTest()
        {
            //Arrange
            RobotAgreggate robot = creator.MakeARobot();

            //Action
            var result = robot.MoveHeadForUp();

            //Assert
            result.IsSuccess.ShouldBeTrue();
            result.Success.ShouldBe(Align.Top);
            robot.HeadAlign.ShouldBe(Align.Top);
        }
コード例 #3
0
        public void RepositoryUpdateRobotTest()
        {
            //Arrange
            RobotAgreggate robot = null;

            robot = repository.Get("099153c2625149bc8ecb3e85e03f0022").Success;

            //Action
            robot.MoveHeadForUp();
            var result = repository.Update(robot);

            //Assert
            result.IsSuccess.ShouldBeTrue();
            result.Success.HeadAlign.ShouldBe(Align.Top);
        }