public void whileLoop2() { EOrientation orientation = EOrientation.East; Robot robot = Robot.Create (orientation, new Map(EDifficulty.Easy)); Solver conditions = new ConcreteInstruction (ECanInstructions.Backward); WhileLoop whileLoop = new WhileLoop (conditions); bool actual = whileLoop.execute (null); bool expected = true; Assert.AreEqual (expected, actual); }
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); }
public void whileLoop1() { EOrientation orientation = EOrientation.East; Robot robot = Robot.Create (orientation, new Map(EDifficulty.Easy)); robot.xPosition = 1; robot.yPosition = 1; Solver condition1 = new ConcreteInstruction (ECanInstructions.Right); Solver condition2 = new ConcreteInstruction (ECanInstructions.Forward); Solver combo = new ConditionCombo (condition1, condition2, ELogicOperators.Or); WhileLoop whileLoop = new WhileLoop (combo); bool actual = whileLoop.execute (null); bool expected = false; Assert.AreEqual (expected, actual); }