Skip to content

Commit

Permalink
Merge pull request #144 from wuseal/optimize/add-unit-test-case-persi…
Browse files Browse the repository at this point in the history
…st-cache

add saveAndReadExceptionInfo and saveAndReadActionInfo unit test
  • Loading branch information
kezhenxu94 authored Apr 15, 2019
2 parents 1f54304 + 3cf2c15 commit 3d10548
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/test/kotlin/wu/seal/jsontokotlin/feedback/PersistCacheTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package wu.seal.jsontokotlin.feedback

import com.google.gson.Gson
import com.winterbe.expekt.should
import org.junit.AfterClass
import org.junit.Before
import org.junit.Test
import wu.seal.jsontokotlin.test.TestConfig.isTestModel

Expand All @@ -10,8 +12,10 @@ import wu.seal.jsontokotlin.test.TestConfig.isTestModel
* Created by Seal.Wu on 2018/2/6.
*/
class PersistCacheTest {
val exceptionInfo = "Test exception"
@Test

private val exceptionInfo = "Test exception"

@Before
fun before() {
isTestModel = true
}
Expand Down Expand Up @@ -46,6 +50,31 @@ class PersistCacheTest {
PersistCache.deleteAllActionInfo()
}

@Test
fun testSaveActionInfoAndReadActionInfo() {

val startActionJSONString = Gson().toJson(StartAction())

PersistCache.saveActionInfo(startActionJSONString)

val readStartActionJSONString = PersistCache.readAllCachedActionInfo().dropLast(1)

readStartActionJSONString.should.be.equal(startActionJSONString)

}


@Test
fun testSaveExceptionInfoAndReadExceptionInfo() {

PersistCache.saveExceptionInfo(exceptionInfo)

val readExceptionInfo = PersistCache.readAllCachedExceptionInfo().dropLast(1)

readExceptionInfo.should.be.equal(exceptionInfo)

}

companion object {
@AfterClass
@JvmStatic
Expand Down

0 comments on commit 3d10548

Please sign in to comment.