Пример #1
0
        public static IDirection CreateDirection(char _direction)
        {
            IDirection roverDirection = null;

            switch (_direction)
            {
            case 'N':
                roverDirection = new NorthDirection();
                break;

            case 'W':
                roverDirection = new WestDirection();
                break;

            case 'S':
                roverDirection = new SouthDirection();
                break;

            case 'E':
                roverDirection = new EastDirection();
                break;

            default: break;
            }

            return(roverDirection);
        }
        public void When_Given_Coordinates_Then_It_Should_Remapping_WestDirection(int x, int y, int calc)
        {
            IDirection direction = new WestDirection();
            var        result    = direction.Remapping(new Coordinate(x, y));

            result.X.Should().Be(calc);
        }
        public void WestDirection_has_correct_name()
        {
            // Act
            var direction = new WestDirection();

            // Assert
            Assert.AreEqual("West", direction.Direction, "The travel direction was not correctly assigned.");
        }
        public void WestDirection_has_correct_reverse_direction()
        {
            // Arrange
            var direction = new WestDirection();

            // Act
            ITravelDirection reverseDirection = direction.GetOppositeDirection();

            // Assert
            Assert.AreEqual("East", reverseDirection.Direction, "The opposite travel direction was not correctly returned.");
        }
        public void Given_WestDirection_When_TurnRight_Then_DirectionShouldBeNorth()
        {
            // Arrange
            WestDirection westDirection = new WestDirection();

            // Act
            IDirection newDirection = westDirection.TurnRight();

            // Assert
            newDirection.Should().BeOfType <NorthDirection>();
        }
        public void Given_WestDirection_When_MoveBackward_Then_ShouldMoveOneUnitRight()
        {
            // Arrange
            WestDirection westDirection = new WestDirection();

            // Act
            Position position    = Position.Origin;
            Position newPosition = westDirection.MoveBackward(position);

            // Assert
            newPosition.Should().BeEquivalentTo(new Position(1, 0));
        }
Пример #7
0
 public void SetUp()
 {
     westDirection = new WestDirection();
 }