public IActionResult CreateCar(CarVM carVM) { var create = _iCar.Create(carVM); if (create > 0) { return(Ok(create)); } return(BadRequest("Not Successfully")); }
private void CreateCarModel() { _printer.Print("Please input board width: "); var width = Console.ReadLine(); _printer.Print("Please input board height: "); var height = Console.ReadLine(); //Assume default orientation is north; _car.Create(width.StringToInt(), height.StringToInt(), Orientation.East); _printer.Print("The Car's start position is the top left corner!"); _printer.ChangeLine(); _printer.Print($"The Car is in position X = {_car.getPositionX()} and Y = {_car.getPositionY()} and facing {_car.getOrientation()}"); _printer.ChangeLine(); }
public void CarShouldMoveToTheCorrectPosition() { _car = new Car(); _command = new MoveCommand(_car); _car.Create(width, height, Orientation.East); _command.Execute(Command.forward.ToString()); _command.Execute(Command.turn.ToString()); _command.Execute(Command.forward.ToString()); _command.Execute(Command.forward.ToString()); _command.Execute(Command.forward.ToString()); _command.Execute(Command.turn.ToString()); _command.Execute(Command.turn.ToString()); _car.getPositionX().Should().Be(1); _car.getPositionY().Should().Be(3); _car.getOrientation().Should().Be(Orientation.North.ToString()); }
public void ShouldThrowExceptionAndRestToPreviousPositionIfCarRunOutOfBoundary() { _car = new Car(); _command = new MoveCommand(_car); _car.Create(width, height, Orientation.East); Action act = () => { for (var i = 0; i < 5; i++) { _command.Execute(Command.forward.ToString()); } }; act.Should().Throw <OutOfBoardException>(); _car.getPositionX().Should().Be(4); _car.getPositionY().Should().Be(0); _car.getOrientation().Should().Be(Orientation.East.ToString()); }