Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@phellipealexandre
Last active May 18, 2022 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phellipealexandre/4c0d9b98167cc7ad456f4792b6125da2 to your computer and use it in GitHub Desktop.
Save phellipealexandre/4c0d9b98167cc7ad456f4792b6125da2 to your computer and use it in GitHub Desktop.
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