### Question:
WhileDoNullaryProcedure extends AbstractLoopNullaryProcedure { public void run() { while (getCondition().test()) { getAction().run(); } } WhileDoNullaryProcedure(NullaryPredicate condition, NullaryProcedure action); void run(); @Override String toString();  }### Answer:
@Test public void testLoopWithAction() throws Exception { List<Object> list=getList(); NullaryProcedure action=new ListRemoveFirstProcedure(list); NullaryPredicate condition=new NullaryNot(new BoundNullaryPredicate(new IsEmpty<List<Object>>(), list)); NullaryProcedure procedure=new WhileDoNullaryProcedure(condition, action); assertTrue("The condition should be true before running the loop", condition.test()); assertFalse("The list should not be empty then", list.isEmpty()); procedure.run(); assertFalse("The condition should be false after running the loop", condition.test()); assertTrue("The list should be empty then", list.isEmpty()); list=getList(); action=new ListRemoveFirstProcedure(list); condition=new NullaryPredicate() { private int count=2; public boolean test() { return count-- > 0; } }; procedure=new WhileDoNullaryProcedure(condition, action); procedure.run(); assertFalse("The list should not contain \"a\" anymore", list.contains("a")); assertFalse("The list should not contain \"b\" anymore", list.contains("b")); assertTrue("The list should still contain \"c\"", list.contains("c")); assertTrue("The list should still contain \"d\"", list.contains("d")); }
@Test public void testLoopForNothing() { List<Object> list=getList(); NullaryProcedure action=new ListRemoveFirstProcedure(list); NullaryProcedure procedure=new WhileDoNullaryProcedure(Constant.FALSE, action); assertTrue("The list should contain 4 elements before runnning the loop", list.size()==4); procedure.run(); assertTrue("The list should contain 4 elements after runnning the loop", list.size()==4); }