Ejemplo n.º 1
0
        public void ShouldMoveNorth()
        {
            var mower = new Mower(0, 0, 0);

            mower.MoveForward();

            Assert.That(mower.Position.Y, Is.EqualTo(1));
            Assert.That(mower.Position.X, Is.EqualTo(0));
        }
Ejemplo n.º 2
0
        public void ShouldMoveWest()
        {
            var mower = new Mower(1, 1, 0);

            mower.MoveRight();
            mower.MoveRight();
            mower.MoveRight();
            mower.MoveForward();

            Assert.That(mower.Position.Y, Is.EqualTo(1));
            Assert.That(mower.Position.X, Is.EqualTo(0));
        }
Ejemplo n.º 3
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();
                }
            }
        }