예제 #1
0
        public void MarsMission_Should_Execute_MoveRoverCommand()
        {
            // Arrange
            var marsMission = new MarsMission();
            var myRover     = new RoverVehicle("Test");

            marsMission.Start(myRover);
            marsMission.ExecuteCommand("5 8");
            marsMission.ExecuteCommand("2 3 S");

            // Act
            try
            {
                marsMission.ExecuteCommand("LMMLMM");
            }
            catch (MissionOverException)
            {
            }

            // Assert
            Assert.Equal(4, myRover.Coordinate.X);
            Assert.Equal(5, myRover.Coordinate.Y);
            Assert.Equal(0, myRover.Rotation.Degree);
            Assert.Equal("Test - 4 5 N", myRover.ToString());
        }
        public void Rover_Should_Move_North_Once()
        {
            // Arrange
            var myRover = new RoverVehicle();

            // Act
            myRover.Move();

            // Assert
            Assert.Equal("N", myRover.Rotation.GetDirection());
            Assert.Equal(0, myRover.Rotation.Degree);
            Assert.Equal(1, myRover.Coordinate.Y);
            Assert.Equal($"{myRover.Name} - 0 1 N", myRover.ToString());
        }
        public void Rover_Should_Move_East_Once()
        {
            // Arrange
            var myRover = new RoverVehicle();

            // Act
            myRover.Rotate(RotationDirection.R);
            myRover.Move();

            // Assert
            Assert.Equal("E", myRover.Rotation.GetDirection());
            Assert.Equal(90, myRover.Rotation.Degree);
            Assert.Equal(1, myRover.Coordinate.X);
            Assert.Equal($"{myRover.Name} - 1 0 E", myRover.ToString());
        }