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 MyPresenterTest { | |
@Test | |
fun onOpenCameraButtonClick_postM() { | |
// Arrange | |
Mockito.`when`(mockBuildProvider.isMarshmallowAndAbove()).thenReturn(true) | |
// Action | |
presenter.onCameraButtonClick() | |
// Assert |
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 MyPresenterTest { | |
@Mock | |
private lateinit var mockBuildProvider: BuildVersionProvider | |
@Mock | |
private lateinit var mockView: MyView | |
private lateinit var presenter: MyPresenter | |
@Before |
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 MyPresenter(val view: MyView, val buildProvider: BuildVersionProvider) : BasePresenter() { | |
override fun onCameraButtonClick() { | |
if (buildProvider.isMarshmallowAndAbove()) { | |
view.requestCameraPermission() | |
} else { | |
navigator.openCamera() | |
} | |
} | |
} |
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 MyPresenterTest { | |
@Test | |
fun onOpenCameraButtonClick_postM() { | |
setFinalStatic(Build.VERSION::class.java.getField("SDK_INT"), 23) | |
// Verify flow request Runtime Permissions | |
// ... | |
} | |
@After |
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
@Throws(Exception::class) | |
fun setFinalStatic(field: Field, newValue: Any) { | |
field.setAccessible(true) | |
val modifiersField = Field::class.java.getDeclaredField("modifiers") | |
modifiersField.setAccessible(true) | |
modifiersField.setInt(field, field.getModifiers() and Modifier.FINAL.inv()) | |
field.set(null, newValue) | |
} |
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
@RunWith(PowerMockRunner::class) | |
@PrepareForTest(Build.VERSION::class) | |
class MyPresenterTest { | |
@Test | |
fun onOpenCameraButtonClick_postM() { | |
Whitebox.setInternalState(Build.VERSION::class.java, "SDK_INT", 23) | |
// Verify flow request Runtime Permissions | |
// ... | |
} |
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
@file:JvmName("SaberUtils") | |
@file:JvmMultifileClass | |
fun makeLightSaber(powers: Int): LightSaber { | |
return LightSaber(powers) | |
} |
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
object SaberUtils { | |
fun makeLightSaber(powers: Int): LightSaber { | |
return LightSaber(powers) | |
} | |
} |
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
object SaberFactory { | |
@JvmStatic fun makeStaticSaber() { /*..*/ } | |
fun makeNonStaticSaber() { /*..*/ } | |
} |
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
// darksaber.kt | |
@file:JvmName("SaberUtils") | |
@file:JvmMultifileClass | |
package org.example | |
fun makeDarkSaber() { /*...*/ } |
NewerOlder