Last active
May 18, 2022 18:23
-
-
Save phellipealexandre/4c0d9b98167cc7ad456f4792b6125da2 to your computer and use it in GitHub Desktop.
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
interface NoteApi { | |
suspend fun uploadNote(note: Note): Result | |
suspend fun fetchAllNotes(): List<Note> | |
} | |
class RealNoteApi: NoteApi { | |
override suspend fun uploadNote(note: Note): Result { | |
//Real impl | |
} | |
override suspend fun fetchAllNotes(): List<Note> { | |
//Real impl | |
} | |
} | |
class FakeNoteApi: NoteApi { | |
private val notes = mutableListOf<Note>() | |
override suspend fun uploadNote(note: Note): Result { | |
notes.add(note) | |
return Result.Success | |
} | |
override suspend fun fetchAllNotes(): List<Note> { | |
return notes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment