-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
221 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
32 changes: 32 additions & 0 deletions
32
test/src/commonMain/kotlin/com/github/kitakkun/backintime/test/MutableCollectionsHolder.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.kitakkun.backintime.test | ||
|
||
import com.github.kitakkun.backintime.annotations.DebuggableStateHolder | ||
|
||
@DebuggableStateHolder | ||
class MutableCollectionsHolder { | ||
private val mutableList = mutableListOf<String>() | ||
private val mutableSet = mutableSetOf<String>() | ||
private val mutableMap = mutableMapOf<String, String>() | ||
|
||
fun mutableListTest() { | ||
mutableList.add("Hello") | ||
mutableList.addAll(listOf("World", "!")) | ||
mutableList.removeAt(1) | ||
mutableList.remove("!") | ||
mutableList.clear() | ||
} | ||
|
||
fun mutableSetTest() { | ||
mutableSet.add("Hello") | ||
mutableSet.addAll(listOf("World", "!")) | ||
mutableSet.remove("!") | ||
mutableSet.clear() | ||
} | ||
|
||
fun mutableMapTest() { | ||
mutableMap["Hello"] = "World" | ||
mutableMap["World"] = "!" | ||
mutableMap.remove("!") | ||
mutableMap.clear() | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
test/src/jvmTest/kotlin/com/github/kitakkun/backintime/test/MutableCollectionsHolderTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.github.kitakkun.backintime.test | ||
|
||
import com.github.kitakkun.backintime.runtime.BackInTimeDebugService | ||
import io.mockk.mockkObject | ||
import io.mockk.unmockkAll | ||
import io.mockk.verify | ||
import org.junit.After | ||
import org.junit.Before | ||
import kotlin.test.Test | ||
|
||
class MutableCollectionsHolderTest { | ||
@Before | ||
fun setup() { | ||
mockkObject(BackInTimeDebugService) | ||
} | ||
|
||
@After | ||
fun teardown() { | ||
unmockkAll() | ||
} | ||
|
||
@Test | ||
fun testMutableListCapture() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.mutableListTest() | ||
|
||
verify(exactly = 5) { | ||
BackInTimeDebugService.notifyPropertyChanged(any(), "mutableList", any(), any()) | ||
} | ||
} | ||
|
||
@Test | ||
fun testMutableSetCapture() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.mutableSetTest() | ||
|
||
verify(exactly = 4) { | ||
BackInTimeDebugService.notifyPropertyChanged(any(), "mutableSet", any(), any()) | ||
} | ||
} | ||
|
||
@Test | ||
fun testMutableMapCapture() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.mutableMapTest() | ||
|
||
verify(exactly = 4) { | ||
BackInTimeDebugService.notifyPropertyChanged(any(), "mutableMap", any(), any()) | ||
} | ||
} | ||
|
||
@Test | ||
fun testMutableListForceSet() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.forceSetValue("mutableList", mutableListOf("Hello", "World", "!")) | ||
mutableCollectionsHolder.forceSetValue("mutableList", listOf("Hello", "World")) | ||
} | ||
|
||
@Test | ||
fun testMutableSetForceSet() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.forceSetValue("mutableSet", mutableSetOf("Hello", "World", "!")) | ||
mutableCollectionsHolder.forceSetValue("mutableSet", setOf("Hello", "World")) | ||
} | ||
|
||
@Test | ||
fun testMutableMapForceSet() { | ||
val mutableCollectionsHolder = MutableCollectionsHolder() | ||
mutableCollectionsHolder.forceSetValue("mutableMap", mutableMapOf("Hello" to "World", "World" to "!")) | ||
mutableCollectionsHolder.forceSetValue("mutableMap", mapOf("Hello" to "World", "World" to "!")) | ||
} | ||
} |