public PositionCreateHandler(GlobalSolusindoDb db, tblM_User user, PositionValidator positionValidator, PositionFactory positionFactory, PositionQuery positionQuery, AccessControl accessControl) : base(db, user) { this.positionValidator = positionValidator; this.positionFactory = positionFactory; this.positionQuery = positionQuery; this.positionEntryDataProvider = new PositionEntryDataProvider(db, user, accessControl, positionQuery); }
public DesignationType(string name, PositionValidator validator, string job, string spriteName) { NAME = name; VALIDATOR = validator; JOB = job; SPRITE_NAME = spriteName; }
public void AcceptValidPostions(string input) { var positionValidator = new PositionValidator(); var result = positionValidator.IsValid(input); Assert.True(result); }
public void DeclineInvalidPostions(string input) { var positionValidator = new PositionValidator(); var result = positionValidator.IsValid(input); Assert.False(result); }
public void TestFromBoardCoordinatesBounds(int inputX, int inputY, bool expected) { var converter = new PositionValidator(); var board = new Board("test", 5, 5); var newCoords = converter.IsPositionValid(board, new Vector2(inputX, inputY)); Assert.Equal(expected, newCoords); }
public void GetValidMoveFromUser() { InputReader inputReader = new TestUserInputReader("1,1"); InputValidator inputValidator = new PositionValidator(); var inputHandler = new UserInputHandler(); var result = inputHandler.GetInput(inputReader, inputValidator); Assert.Equal("1,1", result); }
public void RightCommand_WithoutSetCurrentPosition_Returns_UnchangedPosition() { ICommand rightCommand = new RightCommand(new string[] { }); Position currentPosition = null; IPositionValidator positionValidator = new PositionValidator(5, 5); Position newPosition = rightCommand.Execute(currentPosition, positionValidator); Assert.IsNull(newPosition); }
internal ChessBoardPosition(char horizontal, int vertical) { if (PositionValidator.ValidatePosition(horizontal, vertical) == false) { throw new PositionOutOfBoardException($"Positions are out of the board! Horiontal : {horizontal} Vertical : {vertical}"); } this.Horizontal = horizontal; this.Vertical = vertical; }
public void PlaceCommand_WithoutSetCurrentPosition_AndInvalidNewPositon_Returns_Null() { ICommand placeCommand = new PlaceCommand(new string[] { "5", "1", "NORTH" }); Position currentPosition = null; IPositionValidator positionValidator = new PositionValidator(5, 5); Position newPosition = placeCommand.Execute(currentPosition, positionValidator); Assert.IsNull(newPosition); }
public void Null_Position_Return_False() { int tableLength = 5; int tableWidth = 5; Position currentPosition = null; IPositionValidator positionValidator = new PositionValidator(tableLength, tableWidth); bool isValid = positionValidator.Validate(currentPosition); Assert.That(!isValid); }
public void NulliShootPosition() { var positionValidator = new PositionValidator(); var player = new Player(); var columnSize = 10; var rowSize = 10; bool result = positionValidator.IsShootOk(null, columnSize, rowSize, player); result.Should().BeFalse(); }
public void PlaceCommand_WithoutSetCurrentPosition_AndValidNewPositon_Returns_PlacedPosition() { ICommand placeCommand = new PlaceCommand(new string[] { "1", "1", "NORTH" }); Position currentPosition = null; IPositionValidator positionValidator = new PositionValidator(5, 5); Position newPosition = placeCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.X == 1); Assert.That(newPosition.Y == 1); Assert.That(newPosition.Facing == Direction.NORTH); }
public void NotOverRange() { var positionValidator = new PositionValidator(); var ships = InitializeShips(); var userPosition = new Position(9, 0); var columnSize = 10; var rowSize = 10; bool output = positionValidator.IsValidPosition(userPosition, columnSize, rowSize, ships); output.Should().Be(true); }
public void GetInvalidMoveFromUser() { var orderedInputList = new List <string> { "j", ",2,2", "2,2", "1,1" }; InputReader inputReader = new TestUserInputReader(orderedInputList); InputValidator inputValidator = new PositionValidator(); var inputHandler = new UserInputHandler(); var result = inputHandler.GetInput(inputReader, inputValidator); Assert.Equal("2,2", result); }
public void OutOfBoundX() { var positionValidator = new PositionValidator(); var player = new Player(); var iShootPosition = new Position(11, 0); var columnSize = 10; var rowSize = 10; bool result = positionValidator.IsShootOk(iShootPosition, columnSize, rowSize, player); result.Should().BeFalse(); }
public void NegativeYPosition() { var positionValidator = new PositionValidator(); var player = new Player(); var iShootPosition = new Position(0, -1); var columnSize = 10; var rowSize = 10; bool result = positionValidator.IsShootOk(iShootPosition, columnSize, rowSize, player); result.Should().BeFalse(); }
public void ReportCommand_WithoutSetCurrentPosition_Reports_NotPlacedMessage() { Position currentPosition = null; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand reportCommand = new ReportCommand(new string[] { }); StringWriter reportOutput = new StringWriter(); Console.SetOut(reportOutput); Position newPosition = reportCommand.Execute(currentPosition, positionValidator); Assert.That(reportOutput.ToString() == $"Output: {ErrorMessages.NotPlaced}\r\n"); }
public void NegativeXResturnsfalse() { var positionValidator = new PositionValidator(); var ships = InitializeShips(); var userPosition = new Position(-2, 3); var columnSize = 10; var rowSize = 10; var actual = positionValidator.IsValidPosition(userPosition, columnSize, rowSize, ships); actual.Should().Be(false); }
public void OutOfPlayFieldResturnsFalse() { var positionValidator = new PositionValidator(); var ships = InitializeShips(); var userPosition = new Position(0, 10); var columnSize = 10; var rowSize = 10; var actual = positionValidator.IsValidPosition(userPosition, columnSize, rowSize, ships); actual.Should().Be(false); }
public void Overlap() { var positionValidator = new PositionValidator(); var ships = InitializeShips(); var userPosition = new Position(5, 10); var columnSize = 10; var rowSize = 10; bool output = positionValidator.IsValidPosition(userPosition, columnSize, rowSize, ships); output.Should().Be(false); }
public void Move(int[,] galaxyMatrix, int rows, int cols) { var positionValidator = new PositionValidator(); while (Row >= 0 && Col >= 0) { if (positionValidator.Validate(Row, Col, rows, cols)) { galaxyMatrix[Row, Col] = 0; } Row--; Col--; } }
public void RightCommand_CurrentPositionSouth_SetPositionToWest() { Position currentPosition = new Position { Facing = Direction.SOUTH, X = 0, Y = 0 }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand RightCommand = new RightCommand(new string[] { }); Position newPosition = RightCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.Facing == Direction.WEST); }
public void LeftCommand_CurrentPositionEast_SetPositionToNorth() { Position currentPosition = new Position { Facing = Direction.EAST, X = 0, Y = 0 }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand leftCommand = new LeftCommand(new string[] { }); Position newPosition = leftCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.Facing == Direction.NORTH); }
public void Move(int [,] galaxyMatrix, int rows, int cols) { var positionValidator = new PositionValidator(); while (Row >= 0 && Col < galaxyMatrix.GetLength(1)) { if (positionValidator.Validate(Row, Col, rows, cols)) { CollectedStarsValue += galaxyMatrix[Row, Col]; } Col++; Row--; } }
public void Invalid_Positions_Return_False(int xPosition, int yPosition) { int tableLength = 5; int tableWidth = 5; Position currentPosition = new Position { Facing = Direction.NORTH, X = xPosition, Y = yPosition }; IPositionValidator positionValidator = new PositionValidator(tableLength, tableWidth); bool isValid = positionValidator.Validate(currentPosition); Assert.That(!isValid); }
public void ReportCommand_Returns_UnchangedPosition() { Position currentPosition = new Position { Facing = Direction.NORTH, X = 0, Y = 0 }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand reportCommand = new ReportCommand(new string[] { }); Position newPosition = reportCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.X == currentPosition.X); Assert.That(newPosition.Y == currentPosition.Y); Assert.That(newPosition.Facing == currentPosition.Facing); }
public void MoveCommand_FacingNorth_ReturnsPosition_WillIncreaseY_By1() { Position currentPosition = new Position { Facing = Direction.NORTH, X = 1, Y = 1 }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand moveCommand = new MoveCommand(new string[] { }); Position newPosition = moveCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.X == 1); Assert.That(newPosition.Y == 2); Assert.That(newPosition.Facing == Direction.NORTH); }
public void MoveCommand_FacingWest_ReturnsPosition_WillDecreasedX_By1() { Position currentPosition = new Position { Facing = Direction.WEST, X = 1, Y = 1 }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand moveCommand = new MoveCommand(new string[] { }); Position newPosition = moveCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.X == 0); Assert.That(newPosition.Y == 1); Assert.That(newPosition.Facing == Direction.WEST); }
public void MoveCommand_AttemptToMoveOfEdgeOfTable_ReturnsUnchangedPosition(int xPosition, int yPosition, Direction facing) { Position currentPosition = new Position { Facing = facing, X = xPosition, Y = yPosition }; IPositionValidator positionValidator = new PositionValidator(5, 5); ICommand moveCommand = new MoveCommand(new string[] { }); Position newPosition = moveCommand.Execute(currentPosition, positionValidator); Assert.That(newPosition.X == currentPosition.X); Assert.That(newPosition.Y == currentPosition.Y); Assert.That(newPosition.Facing == currentPosition.Facing); }
public void CorrectlyPosition() { var positionValidator = new PositionValidator(); var player = new Player(); player.Positions = new List <Position>(); player.Hits = new List <Hit>(); var iShootPosition = new Position(1, 2); var columnSize = 10; var rowSize = 10; bool result = positionValidator.IsShootOk(iShootPosition, columnSize, rowSize, player); result.Should().BeTrue(); }
public void OnSetup() { _validator = new PositionValidator(5, 5); }