Created
July 21, 2018 19:01
-
-
Save marcelpinto/20f1f882d4040c81314a1d697f10a75e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class NetworkFactoryTest { | |
private val baseUrl = "/" | |
private val testData = TestData("hello!") | |
private val testDataJson = "{\"name\":\"${testData.name}\"}" | |
private val mockWebServer = MockWebServer() | |
private val httpUrl = mockWebServer.url(baseUrl) | |
private val moshi = createMoshi() | |
private val authenticator = MyAuthenticator() | |
private val tokenStorage = mock<TokenStorage>() | |
private lateinit var tested: NetworkFactory | |
private lateinit var testApi: TestApi | |
@Before | |
fun setUp() { | |
val authInterceptor = AuthenticationInterceptor(tokenStorage) | |
tested = NetworkFactory(moshi, authInterceptor, authenticator) | |
testApi = tested.createApi(TestApi::class.java, httpUrl.toString()) | |
} | |
} | |
private interface TestApi { | |
@GET("/test") | |
fun test(): Call<TestData> | |
} | |
private data class TestData(val name: String) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment