public void RotateHeadToTheRightTwoTimesTest() { //Arrange RobotAgreggate robot = creator.MakeARobot(); //Action robot.RotateHeadToTheRight(); var result = robot.RotateHeadToTheRight(); //Assert result.IsSuccess.ShouldBeTrue(); result.Success.ShouldBe(-90); robot.HeadDirection.ShouldBe(-90); }
private Result <Exception, int> ProcessHeadRotate(HeadRotateCommand command, RobotAgreggate robot) { Result <Exception, int> rotateCallback; switch (command.HeadRotate.ToLower()) { case "left": rotateCallback = robot.RotateHeadToTheLeft(); break; case "right": rotateCallback = robot.RotateHeadToTheRight(); break; default: return(new BussinessException(ErrorCodes.BadRequest, "Comando inválido.")); } // Publish Domain Events _mediator.PublishDomainEvents(robot.RaisedEvents()); if (rotateCallback.IsSuccess) { return(PersistRobotState(robot, rotateCallback.Success)); } return(rotateCallback.Failure); }