Skip to content

Instantly share code, notes, and snippets.

@kmdupr33
Created April 24, 2015 10:50
Show Gist options
  • Select an option

  • Save kmdupr33/528c6094c43a74f8c0be to your computer and use it in GitHub Desktop.

Select an option

Save kmdupr33/528c6094c43a74f8c0be to your computer and use it in GitHub Desktop.
public void testCacheUpdate() {
//Arrange
CalculationCache calcCache = mock(CalculationCache.class);
when(calcCache.contains()).thenReturn(false);
Calculator calculator = mock(Calculator.class);
MathNerd mathNerd = new MathNerd(calcCache, calculator);
Calculation calculation = new Calculation("e^2000");
//Act
mathNerd.doIntenseCalculationInBackground(calculation, null);
//Assert should use calculator to perform calcluation because cache was empty
verify(calculator).doIntenseCalculationInBackground(any());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment