Giter Site home page Giter Site logo

eranboudjnah / cleanarchitectureforandroid Goto Github PK

View Code? Open in Web Editor NEW
407.0 7.0 51.0 4.11 MB

Clean Architecture for Android - a sample project

Home Page: https://amzn.to/3rBSxOb

License: MIT License

Kotlin 99.92% Shell 0.08%
android android-testing clean-architecture hilt-android jetpack-compose kotlin-android multi-module-project mvvm clean-architecture-android multimodule-android-app

cleanarchitectureforandroid's People

Contributors

eranboudjnah avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cleanarchitectureforandroid's Issues

[Question]: Parameterized test

Hello Eran. I am on the process of reading your book and came across to the testing of the model mappers.

On the file SavedIpAddressRecordToPresentationMapperTest.kt how does the actualValue work? I mean when you call the toPresentation that should return different instance of an object right? so why the test succeeded?

val actualValue = classUnderTest.toPresentation(givenSavedRecord)

When I tried I have a failure test. Even though my expected and actual are the same they are different object since classUnderTest.toPresentation(givenSavedRecord) will create a new instance

here is my error

Expected :link.limecode.newsfeed.presentation.model.pagination.PaginationPresentationModel@7bd7d6d6
Actual   :link.limecode.newsfeed.presentation.model.pagination.PaginationPresentationModel@50029372

I cant wrap around my head why does yours works and mine did not

here is my full class

package link.limecode.newsfeed.presentation.mapper

import link.limecode.newsfeed.domain.model.pagination.PaginationDomainModel
import link.limecode.newsfeed.presentation.model.pagination.PaginationPresentationModel
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters

@RunWith(Parameterized::class)
class PaginationToPresentationMapperTest(
    private val given: PaginationDomainModel,
    private val expected: PaginationPresentationModel
) {
    companion object {
        @JvmStatic
        @Parameters(name = "Given {0} then {1}")
        fun data(): Collection<Array<*>> = listOf(
            testCase(
                nextCursor = null,
                prevCursor = null
            ),
            testCase(
                nextCursor = "next_id",
                prevCursor = null
            ),
            testCase(
                nextCursor = null,
                prevCursor = "prev_id"
            )
        )

        private fun testCase(
            nextCursor: String?,
            prevCursor: String?
        ) = arrayOf(
            PaginationDomainModel(
                nextCursor = nextCursor,
                prevCursor = prevCursor
            ),
            PaginationPresentationModel(
                nextCursor = nextCursor,
                prevCursor = prevCursor
            )
        )
    }

    private lateinit var classUnderTest: PaginationToPresentationMapper

    @Before
    fun setUp() {
        classUnderTest = PaginationToPresentationMapper()
    }

    @Test
    fun `When toPresentation`() {
        // given

        // when
        val actual = classUnderTest.toPresentation(given)

        // then
        assertEquals(expected, actual)
    }
}

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.