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
@Composable | |
fun LinearChart( | |
modifier: Modifier = Modifier, | |
style: LinearChartStyle = LinearChartStyle.Default, | |
data: List<Int> | |
) { | |
Canvas(modifier = modifier) { | |
// distance between each x point | |
val distance = size.width / (data.size + 1) | |
var currentX = 0F |
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 `should take posts and display it when call takePosts`() { | |
// given | |
val posts = listOf<Post>(mockk(), mockk()) | |
val observerDisplayingView = spyk<Observer<Int>>() | |
val displayingViewResults = mutableListOf<Int>() | |
val observerPostResult = spyk<Observer<List<Post>>>() | |
val postResults = mutableListOf<List<Post>>() |
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
fun takePosts() { | |
compositeDisposable + useCase.takePosts() | |
.subscribeOn(appSchedulers.io) | |
.observeOn(appSchedulers.main) | |
.doOnSubscribe { _displayingView.value = DisplayingView.Loading.ordinal } | |
.subscribeBy(onError = { | |
_displayingView.value = DisplayingView.Error.ordinal | |
_errorMessage.value = it.message ?: DEFAULT_ERROR_MESSAGE | |
}, onSuccess = { result -> | |
if (result.isNotEmpty()) { |
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
// given | |
val posts = listOf<PostResponse>(mockk(), mockk()) | |
every { repository.getPosts() } returns Single.just(posts) | |
// when | |
val result = repository.getPosts() | |
// then | |
result.test() | |
.assertResult(posts) |
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 PostsRepository { | |
fun getPosts(): Single<List<PostResponse>> | |
} | |
class PostsRepositoryImpl @Inject constructor( | |
private val service: PostService | |
) : PostsRepository { | |
override fun getPosts(): Single<List<PostResponse>> = service.getPosts() | |
} |