From 38f7c9628821831c328a51fe51dcb844a9746d52 Mon Sep 17 00:00:00 2001 From: Seal Date: Sun, 14 Apr 2019 15:15:06 +0800 Subject: [PATCH] add saveAndReadExceptionInfo unit test and saveAndReadActionInfo unit test --- .../jsontokotlin/feedback/PersistCacheTest.kt | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/wu/seal/jsontokotlin/feedback/PersistCacheTest.kt b/src/test/kotlin/wu/seal/jsontokotlin/feedback/PersistCacheTest.kt index 91ff0266..22ca2978 100644 --- a/src/test/kotlin/wu/seal/jsontokotlin/feedback/PersistCacheTest.kt +++ b/src/test/kotlin/wu/seal/jsontokotlin/feedback/PersistCacheTest.kt @@ -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 @@ -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 } @@ -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