### Question:
RandomCommand { public String next() { int count = dice.next(100); String result = ""; for (int i = 0; i < count; i++) { int command = dice.next(parts.size()); result += parts.get(command); } return result; } RandomCommand(Dice dice); String next();  }### Answer:
@Test public void shouldGenerate() { Dice dice = mock(Dice.class); RandomCommand generator = new RandomCommand(dice); when(dice.next(100)).thenReturn(6*3); when(dice.next(6*3)).thenReturn(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); String next = generator.next(); assertEquals("BB2B'DD2D'FF2F'LL2L'RR2R'UU2U'", next); }