Exemple #1
0
        public void Should_parse_position_from_string()
        {
            //Given
            var position = ParsePosition.From("1 2 N");

            //Then
            Assert.That(position.Coordinate.X, Is.EqualTo(1));
            Assert.That(position.Coordinate.Y, Is.EqualTo(2));
            Assert.That(position.Orientation, Is.EqualTo(Orientation.N));
        }
Exemple #2
0
        public void Should_return_1_RoverCommand()
        {
            //Given
            var commandStrings = new List <string> {
                "5 5", "1 1 N", "MM"
            };
            //When
            var roverCommands = ParseRobotCommands.From(commandStrings);

            //Then
            Assert.That(roverCommands.Count(), Is.EqualTo(1), "Should parser only 1 RoverCommand");

            var robotCommand = roverCommands.First();

            Assert.That(robotCommand.StartingPosition, Is.EqualTo(ParsePosition.From("1 1 N")));
        }
Exemple #3
0
        public void Should_throw_exception_when_given_invalid_position_input_string()
        {
            const string invalidPositionString = "THIS IS NOT A VALID POSITION";
            var          exception             = Assert.Throws <CouldNotParsePositionException>(() => ParsePosition.From(invalidPositionString));

            Assert.That(exception.Message, Is.EqualTo("Could not parse position from: " + invalidPositionString));
        }