/** Next low number guess test. */ @Test public void nextLowNumberGuessTest() { when(rangeGenerator.generateRange(4)).thenReturn(new Range(16, 32)); long nextHighNumber = nextGuess.nextLowNumber(16); assertThat(nextHighNumber, is(16L)); verify(rangeGenerator).generateRange(4); }
/** Next high number guess test. */ @Test public void nextHighNumberGuessTest() { when(rangeGenerator.generateRange(6)).thenReturn(new Range(64, 128)); long nextHighNumber = nextGuess.nextHighNumber(64); assertThat(nextHighNumber, is(128L)); verify(rangeGenerator).generateRange(6); }
/** Next low number fine grained guess test. */ @Test public void nextLowNumberFineGrainedGuessTest() { ReflectionTestUtils.setField(nextGuess, "fineGrainedGuesser", fineGrainedGuess); int currentNum = 27; when(fineGrainedGuess.moveToPreviousRange(currentNum)).thenReturn(false); when(fineGrainedGuess.nextLowNumber(27)).thenReturn(26L); long nextLow = nextGuess.nextLowNumber(currentNum); assertThat(nextLow, is(26L)); verify(rangeGenerator, never()).generateRange(Matchers.anyInt()); verify(fineGrainedGuess, times(1)).moveToPreviousRange(currentNum); verify(fineGrainedGuess, times(1)).nextLowNumber(currentNum); }