verify static calls on mocked classes
This commit is contained in:
parent
f739980988
commit
9be0ffffa9
|
@ -63,24 +63,43 @@ class VersionCheckerUtilsKtTest {
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update1`() {
|
fun `should find update1`() {
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update2`() {
|
fun `should find update2`() {
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update3`() {
|
fun `should find update3`() {
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -91,6 +110,10 @@ class VersionCheckerUtilsKtTest {
|
||||||
compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1")
|
compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -98,16 +121,25 @@ class VersionCheckerUtilsKtTest {
|
||||||
fun `should find update5`() {
|
fun `should find update5`() {
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev")
|
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update6`() {
|
fun `should find update6`() {
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
val sp = prepareSP()
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev")
|
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -122,8 +154,12 @@ class VersionCheckerUtilsKtTest {
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2")
|
compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2")
|
||||||
|
|
||||||
verify(bus, times(0)).post(any())
|
verify(bus, times(0)).post(any())
|
||||||
verify(SP, times(1)).remove(R.string.key_new_version_available_since)
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.remove(eq(R.string.key_new_version_available_since))
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -138,7 +174,12 @@ class VersionCheckerUtilsKtTest {
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
val bus = prepareBus()
|
val bus = prepareBus()
|
||||||
compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2")
|
compareWithCurrentVersion(buildGradle.byteInputStream().findVersion(), currentVersion = "2.2.2")
|
||||||
|
|
||||||
verify(bus, times(1)).post(any())
|
verify(bus, times(1)).post(any())
|
||||||
|
|
||||||
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
SP.putLong(eq(R.string.key_new_version_available_since), ArgumentMatchers.anyLong())
|
||||||
|
PowerMockito.verifyNoMoreInteractions(SP::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue