public void TryMoveAhead_NullPosition_ThrowArgumentNullException() { //Arrange ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act and Assert var exception = Assert.Throws <ArgumentNullException>(() => cardinalDirectionManager.TryMoveAhead(null)); Assert.AreEqual("Value cannot be null. (Parameter 'position')", exception.Message); }
public void TurnLeft_FromNorth_ToWest() { //Arrange ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act ICardinalDirectionManager leftFacing = cardinalDirectionManager.TurnLeft(); //Assert Assert.AreEqual(CardinalDirection.WEST, leftFacing.CardinalDirection); }
public void TurnRight_FromNorth_ToEast() { //Arrange ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act ICardinalDirectionManager rightFacing = cardinalDirectionManager.TurnRight(); //Assert Assert.AreEqual(CardinalDirection.EAST, rightFacing.CardinalDirection); }
public void CardinalDirection_ReadCardinalDirection_North() { //Arrange ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act CardinalDirection facing = cardinalDirectionManager.CardinalDirection; //Assert Assert.AreEqual(CardinalDirection.NORTH, facing); }
public void TryMoveAhead_FromNorthestPosition_DontMove() { //Arrange var currentPosition = new Position(0, 4); ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act Position finalPosition = cardinalDirectionManager.TryMoveAhead(currentPosition); //Assert Assert.AreEqual(0, finalPosition.X); Assert.AreEqual(4, finalPosition.Y); }
public void TryMoveAhead_FromNotBorderPosition_IncreaseY() { //Arrange var currentPosition = new Position(1, 1); ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); //Act Position finalPosition = cardinalDirectionManager.TryMoveAhead(currentPosition); //Assert Assert.AreEqual(1, finalPosition.X); Assert.AreEqual(2, finalPosition.Y); }
public void GetToyRobotState_ReadState_CorrectValues() { //Arrange var currentPosition = new Position(1, 2); ICardinalDirectionManager cardinalDirectionManager = new NorthManager(); var toyRobotManager = new ToyRobot(currentPosition, cardinalDirectionManager, new ReportManager()); //Act ToyRobotState toyRobotState = toyRobotManager.GetState(); //Assert Assert.AreEqual(1, toyRobotState.X); Assert.AreEqual(2, toyRobotState.Y); Assert.AreEqual(CardinalDirection.NORTH, toyRobotState.CardinalDirection); }
public void Report_PrintPositionAndDirection_CheckConsoleWrapperIsCalled() { //Arrange var currentPosition = new Position(0, 0); ICardinalDirectionManager facingManager = new NorthManager(); var reportManagerMock = new Mock <IReportManager>(); reportManagerMock.Setup(reportManager => reportManager.Report(It.IsAny <ToyRobotState>())); var toyRobotManager = new ToyRobot(currentPosition, facingManager, reportManagerMock.Object); //Act toyRobotManager.Report(); //Assert reportManagerMock.Verify(reportManager => reportManager.Report(It.IsAny <ToyRobotState>()), Times.Once()); }