public void ShouldMoveLeft() { var mower = new Mower(0, 0, 0); mower.MoveLeft(); Assert.That(mower.Direction, Is.EqualTo(3)); mower.MoveLeft(); Assert.That(mower.Direction, Is.EqualTo(2)); mower.MoveLeft(); Assert.That(mower.Direction, Is.EqualTo(1)); mower.MoveLeft(); 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(); } } }