Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CollectiveHealth-gists/dd79f27dbfe732b78cc396335932fc4b to your computer and use it in GitHub Desktop.
Save CollectiveHealth-gists/dd79f27dbfe732b78cc396335932fc4b to your computer and use it in GitHub Desktop.
ComputerTest implemented using setters.
public class ComputerTestUsingSetter {
@Test
public void testPlayVideo() {
Computer computer = new Computer();
MotherBoard motherBoard = new MotherBoard();
SoundCard soundCard = new SoundCard();
VideoCard videoCard = new VideoCard();
SoundSystem soundSystem = Mockito.mock(SoundSystem.class);
DisplaySystem displaySystem = Mockito.mock(DisplaySystem.class);
computer.setMotherBoard(motherBoard);
motherBoard.setSoundCard(soundCard);
motherBoard.setVideoCard(videoCard);
soundCard.setConnectedExternalSystem(soundSystem);
videoCard.setConnectedExternalSystem(displaySystem);
computer.playVideo();
Mockito.verify(soundSystem).playAudio(Mockito.any());
Mockito.verify(displaySystem).playVideo(Mockito.any());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment