コード例 #1
0
        public void ShouldMoveLeftOffCommand()
        {
            var mower = new Mower(0, 0, 0);

            mower.RunCommand("LL");

            Assert.That(mower.Direction, Is.EqualTo(2));
        }
コード例 #2
0
        public void ShouldMoveForwardOffCommand()
        {
            var mower = new Mower(0, 0, 0);

            mower.RunCommand("MM");

            Assert.That(mower.Position.Y, Is.EqualTo(2));
        }
コード例 #3
0
        public void ShouldMoveRightOffCommand()
        {
            var mower = new Mower(0, 0, 0);

            mower.RunCommand("RRR");

            Assert.That(mower.Direction, Is.EqualTo(3));
        }
コード例 #4
0
        public void ShouldRunFullCommand1()
        {
            var mower = new Mower(3, 3, 1);

            mower.RunCommand("MMRMMRMRRM");

            Assert.That(mower.Position.X, Is.EqualTo(5));
            Assert.That(mower.Position.Y, Is.EqualTo(1));
            Assert.That(mower.Direction, Is.EqualTo(1));
        }
コード例 #5
0
        public void ShouldRunFullCommand()
        {
            var mower = new Mower(1, 2, 0);

            mower.RunCommand("LMLMLMLMM");

            Assert.That(mower.Position.X, Is.EqualTo(1));
            Assert.That(mower.Position.Y, Is.EqualTo(3));
            Assert.That(mower.Direction, Is.EqualTo(0));
        }
コード例 #6
0
        /// <summary>
        /// Drive our mower will throw in mower not initialised
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public string RunCommand(string command)
        {
            if (_currentMower == null)
            {
                throw new NullReferenceException("Please run InitMower() before running command");
            }

            _currentMower.RunCommand(command);

            return(_currentMower.ToString());
        }