예제 #1
0
        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);
        }
예제 #2
0
        public void TurnLeft_FromNorth_ToWest()
        {
            //Arrange
            ICardinalDirectionManager cardinalDirectionManager = new NorthManager();

            //Act
            ICardinalDirectionManager leftFacing = cardinalDirectionManager.TurnLeft();

            //Assert
            Assert.AreEqual(CardinalDirection.WEST, leftFacing.CardinalDirection);
        }
예제 #3
0
        public void TurnRight_FromNorth_ToEast()
        {
            //Arrange
            ICardinalDirectionManager cardinalDirectionManager = new NorthManager();

            //Act
            ICardinalDirectionManager rightFacing = cardinalDirectionManager.TurnRight();

            //Assert
            Assert.AreEqual(CardinalDirection.EAST, rightFacing.CardinalDirection);
        }
예제 #4
0
        public void CardinalDirection_ReadCardinalDirection_North()
        {
            //Arrange
            ICardinalDirectionManager cardinalDirectionManager = new NorthManager();

            //Act
            CardinalDirection facing = cardinalDirectionManager.CardinalDirection;

            //Assert
            Assert.AreEqual(CardinalDirection.NORTH, facing);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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());
        }