public void whileLoop3()
        {
            EOrientation orientation = EOrientation.East;
            Robot robot = Robot.Create (orientation, new Map(EDifficulty.Easy));

            Solver concreteInstruction1 = new ConcreteInstruction (ECanInstructions.Forward); //A
            Solver concreteInstruction2 = new ConcreteInstruction (ECanInstructions.Forward); //A
            Solver notInstruction = new ConditionCombo (concreteInstruction1, ELogicOperators.Not); //!A
            Solver combo = new ConditionCombo (notInstruction, concreteInstruction2, ELogicOperators.And); // !A && A

            ICodeBlock command = new TurnRight ();

            WhileLoop whileLoop = new WhileLoop (combo);
            whileLoop.addChild (command);
            whileLoop.execute (null);

            EOrientation actual = robot.orientationEnum;
            EOrientation expected = EOrientation.East;
            Assert.AreEqual (expected, actual);
        }
 /// Author: Max Hamulyak
 /// Date:	08-06-2015
 /// <summary>
 /// Takes a single <see cref="Token"/> and parses it to a robot instruction.
 /// Like <see cref="PickUp"/>, <see cref="Forward"/> and <see cref="TurnRight"/>
 /// that are all of the return type <see cref="Command"/>
 /// </summary>
 /// <returns>The <see cref="Command"/> from token.</returns>
 /// <param name="tokenToParse">Command token.</param>
 protected override Command SimpleCommandFromToken(List<Token> tokensToParse, int currentLine)
 {
     Token tokenToParse = tokensToParse.First ();
     tokensToParse.Remove (tokenToParse);
     tokensToParse.RemoveAll (x => x.Type == ETokenType.CommentLine || x.Type == ETokenType.EOL || x.Type == ETokenType.WhiteSpace);
     if (tokensToParse.Count > 0) {
         throw TokenAfterFunctionCall (currentLine, tokenToParse.Value, tokensToParse.First ().Value);
     } else {
         Command robotCommand;
         if (tokenToParse.Value == "moveForward()") {
             robotCommand = new Forward ();
         } else if (tokenToParse.Value == "rotateRight()") {
             robotCommand = new TurnRight ();
         } else {
             int quoteIndex = tokenToParse.Value.IndexOf ("'");
             String desiredObject = tokenToParse.Value.Substring (quoteIndex + 1);
             desiredObject = desiredObject.TrimEnd ("')".ToCharArray ());
             robotCommand = new PickUp (desiredObject);
         }
         robotCommand.LineNumber = tokenToParse.Position.Line;
         return robotCommand;
     }
 }
        public void ifStatement2()
        {
            EOrientation orientation = EOrientation.East;
            Robot robot = Robot.Create (orientation, new Map(EDifficulty.Easy));
            robot.xPosition = 0;
            robot.yPosition = 0;

            Solver conditions = new ConcreteInstruction (ECanInstructions.Backward);

            ICodeBlock command = new TurnRight ();

            IfStatement ifStatement = new IfStatement (conditions);
            ifStatement.ElseChildren.Add (command);
            ifStatement.execute (null);

            EOrientation actual = robot.orientationEnum;
            EOrientation expected = EOrientation.South;
            Assert.AreEqual (expected, actual);
        }