Created
January 28, 2011 08:34
-
-
Save alinpopa/800002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ScannerTest { | |
| @Test | |
| public void shouldDisplayThePriceUsingTaxes() { | |
| Display display = mock(Display.class); | |
| Calculator calculator = mock(Calculator.class); | |
| Repository repository = mock(Repository.class); | |
| when(calculator.calculate("$100")).thenReturn("$119"); | |
| when(repository.getProductPrice("ABC123")).thenReturn("$100"); | |
| Scanner scanner = new Scanner(repository, calculator, display); | |
| scanner.scan("ABC123"); | |
| verify(display).print("$119"); | |
| } | |
| @Test | |
| public void shouldUseTheRepositoryWhenScanning() { | |
| Display display = mock(Display.class); | |
| Calculator calculator = mock(Calculator.class); | |
| Repository repository = mock(Repository.class); | |
| when(calculator.calculate("$100")).thenReturn("$119"); | |
| Scanner scanner = new Scanner(repository, calculator, display); | |
| scanner.scan("ABC123"); | |
| verify(repository).getProductPrice("ABC123"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment