Last active
November 14, 2020 11:29
-
-
Save phellipealexandre/3bf4e745ff69f71034d18efbe08d8ef5 to your computer and use it in GitHub Desktop.
Exemplo onde substituímos a dependência de uma API por um Fake. O comportamento desse Fake estará implementado na própria classe FakeNoteApi.
This file contains 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
@Test | |
fun `Retrieve all notes when requested`() { | |
//Dublê de teste Fake. Implementa a mesma interface do original. | |
val noteApiFake = FakeNoteApi() | |
val noteRepository = NoteRepository(noteApiFake) | |
val note = //Dublê de teste Dummy | |
noteApiFake.uploadNote(note) | |
noteApiFake.uploadNote(note) | |
//Fake será utilizado por debaixo dos panos com uma implementação real | |
val allNotesCount = noteRepository.getNoteCount() | |
assertEquals(expected = 2, actual = allNotesCount) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment