Skip to content

Instantly share code, notes, and snippets.

@kmdupr33
Last active August 29, 2015 14:19
Show Gist options
  • Save kmdupr33/5979104560afac8b525d to your computer and use it in GitHub Desktop.
Save kmdupr33/5979104560afac8b525d to your computer and use it in GitHub Desktop.
public void testSquare() {
TerribleMathStudent terribleMathStudent = new TerribleMathStudent();
terribleMathStudent.setCalculator(new BrokenCalculator());
//terribleMathStudent uses broken calculator to do this, so this student really sucks
int result = terribleMathStudent.square(2);
assertNotEquals(result, 4);
//we pity the terrible math student, so we give him a working calculator
terribleMathStudent.setCalculator(new Calculator());
result = terribleMathStudent.square(2);
assertEquals(result, 4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment