Example #1
0
        public void Robert_PlacedOutOfTableY()
        {
            // Given
            IRobert target = new Robert(new TableDimension(width: 6, hight: 5));

            // When
            target.Place(new Position(x: 5, y: 5), Direction.North);

            // Then
            Assert.IsNull(target.CurrentPosition);
        }
Example #2
0
        public void Robert_PlacedOnTable()
        {
            // Given
            IRobert target = new Robert(new TableDimension(width: 5, hight: 5));

            // When
            target.Place(new Position(x: 4, y: 3), Direction.North);

            // Then
            Assert.IsNotNull(target.CurrentPosition);
            Assert.AreEqual(new Position(x: 4, y: 3), target.CurrentPosition.Value);
            Assert.AreEqual(Direction.North, target.CurrentDirection.Value);
        }
Example #3
0
        private static void TestMove(Direction direction, Position currentPosition, Position nextPosition)
        {
            // Given
            IRobert target = new Robert(new TableDimension(width: 5, hight: 5));

            target.Place(currentPosition, direction);

            // When
            target.Move();

            // Then
            Assert.AreEqual(nextPosition, target.CurrentPosition.Value);
            Assert.AreEqual(direction, target.CurrentDirection.Value);
        }
Example #4
0
        private static void TestDirection(Direction currentDirection, Direction nextDirection, Action <IRobert> turn)
        {
            // Given
            IRobert target = new Robert(new TableDimension(width: 5, hight: 5));

            target.Place(new Position(x: 3, y: 3), currentDirection);

            // When
            turn(target);

            // Then
            Assert.IsNotNull(target.CurrentPosition);
            Assert.AreEqual(new Position(x: 3, y: 3), target.CurrentPosition.Value);
            Assert.AreEqual(nextDirection, target.CurrentDirection.Value);
        }
Example #5
0
        public void Robert_ReportPosition()
        {
            // Given
            IRobert target = new Robert(new TableDimension(width: 5, hight: 5));

            target.Place(new Position(x: 4, y: 3), Direction.North);

            // When
            string actual = null;

            target.Report(report => actual = report);

            // Then
            var expected = "4,3,NORTH";

            Assert.AreEqual(expected, actual);
        }