Esempio n. 1
0
        public void Parse__Command_Exception()
        {
            string        cmd    = "ALRR345";
            CommandParser parser = new CommandParser();
            IPosition     p      = new Rover.Position.Position(0, 0, 'N');

            Assert.ThrowsException <ArgumentException>(() => parser.ParseDisplacement(cmd, p));
        }
Esempio n. 2
0
        public void Test_Parse_Command()
        {
            string        cmd    = "RRLR1R2R45L9L6L45";
            CommandParser parser = new CommandParser();
            IPosition     p      = new Rover.Position.Position(0, 0, 'N');
            var           lstCmd = parser.ParseDisplacement(cmd, p) as List <ICommand>;

            Assert.AreEqual(15, lstCmd.Count());
            Assert.IsTrue(lstCmd[0] is Rover.Position.Rotate);  //R
            Assert.IsTrue(lstCmd[1] is Rover.Position.Rotate);  //R
            Assert.IsTrue(lstCmd[2] is Rover.Position.Rotate);  //L
            Assert.IsTrue(lstCmd[3] is Rover.Position.Rotate);  //R
            Assert.IsTrue(lstCmd[4] is Rover.Position.Move);    //1
            Assert.IsTrue(lstCmd[5] is Rover.Position.Rotate);  //R
            Assert.IsTrue(lstCmd[6] is Rover.Position.Move);    //2
            Assert.IsTrue(lstCmd[7] is Rover.Position.Rotate);  //R
            Assert.IsTrue(lstCmd[8] is Rover.Position.Move);    //45
            Assert.IsTrue(lstCmd[9] is Rover.Position.Rotate);  //L
            Assert.IsTrue(lstCmd[10] is Rover.Position.Move);   //9
            Assert.IsTrue(lstCmd[11] is Rover.Position.Rotate); //L
            Assert.IsTrue(lstCmd[12] is Rover.Position.Move);   //6
            Assert.IsTrue(lstCmd[13] is Rover.Position.Rotate); //L
            Assert.IsTrue(lstCmd[14] is Rover.Position.Move);   //45
        }