Skip to content

Instantly share code, notes, and snippets.

@phellipealexandre
Last active May 18, 2022 17:53
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/9f38486fc8a3026c8382100f4816f9b6 to your computer and use it in GitHub Desktop.
Save phellipealexandre/9f38486fc8a3026c8382100f4816f9b6 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 implementation
}
override suspend fun fetchAllNotes(): List<Note> {
//Real implementation
}
}
class StubNoteApi(
val notes: List<Note> = listOf(),
val result: Result = Result.Success
) : NoteApi {
override suspend fun uploadNote(note: Note): Result {
return result
}
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