public void ShouldMoveSouth() { var mower = new Mower(0, 1, 0); mower.MoveRight(); mower.MoveRight(); mower.MoveForward(); Assert.That(mower.Position.Y, Is.EqualTo(0)); Assert.That(mower.Position.X, Is.EqualTo(0)); }
public void ShouldMoveRight() { var mower = new Mower(0, 0, 0); mower.MoveRight(); Assert.That(mower.Direction, Is.EqualTo(1)); mower.MoveRight(); Assert.That(mower.Direction, Is.EqualTo(2)); mower.MoveRight(); Assert.That(mower.Direction, Is.EqualTo(3)); mower.MoveRight(); Assert.That(mower.Direction, Is.EqualTo(0)); }
/// <summary> /// Run commands /// </summary> /// <param name="mower"></param> /// <param name="commands"></param> internal static void RunCommand(this Mower mower, string commands) { var moves = commands.Trim().ToLower().ToCharArray(); foreach (var command in moves) { if (command.Equals('l')) { mower.MoveLeft(); } else if (command.Equals('r')) { mower.MoveRight(); } else if (command.Equals('m')) { mower.MoveForward(); } } }