@@ -2,6 +2,7 @@ package com.github.pcpl2.simplecache
22
33import android.support.test.InstrumentationRegistry
44import android.support.test.runner.AndroidJUnit4
5+ import android.util.Log
56import com.github.pcpl2.simplecache.models.TestObject
67
78import org.junit.Test
@@ -26,71 +27,71 @@ class SimpleCacheTest {
2627
2728 val cacheManager = CacheManager .createInstance(appContext, null )
2829
29- cacheManager.add (" String" , " Hello World" )
30- cacheManager.add (" Int" , 255 )
31- cacheManager.add (" Bool" , false )
32- cacheManager.add (" float" , 5.55 )
30+ cacheManager.set (" String" , " Hello World" )
31+ cacheManager.set (" Int" , 255 )
32+ cacheManager.set (" Bool" , false )
33+ cacheManager.set (" float" , 5.55 )
3334 val testMap = HashMap <String , String >()
3435 testMap[" testKey" ] = " TestValue"
35- cacheManager.add (" map" , testMap)
36+ cacheManager.set (" map" , testMap)
3637 val testObject = TestObject (69 , " abababa" , false , 6.66f , testMap)
37- cacheManager.add (" obj" , testObject)
38+ cacheManager.set (" obj" , testObject)
3839 val testObject2 = TestObject (885 , " Testing two!" , true , 3.14f , testMap)
3940
40- cacheManager.add (" obj2" , testObject2)
41+ cacheManager.set (" obj2" , testObject2)
4142
4243 cacheManager.get(key = " String" , success = { value, type ->
4344 assertEquals(" Hello World" , value)
44- assert (type!! .isInstance(String ::class ))
45- System . out . println ( value.toString())
45+ assert (type.isInstance(String ::class ))
46+ Log .d( " simpleCacheTest " , value.toString())
4647 })
4748
48- cacheManager.get(key = " Int" , success = { value, type ->
49+ cacheManager.get(key = " Int" , checkExpired = true , success = { value, type ->
4950 assertEquals(255 , value)
50- assert (type!! .isInstance(Int ::class ))
51- System . out . println ( value.toString())
51+ assert (type.isInstance(Int ::class ))
52+ Log .d( " simpleCacheTest " , value.toString())
5253 })
5354
5455 cacheManager.get(key = " Bool" , success = { value, type ->
5556 assertEquals(false , value)
56- assert (type!! .isInstance(Boolean ::class ))
57- System . out . println ( value.toString())
57+ assert (type.isInstance(Boolean ::class ))
58+ Log .d( " simpleCacheTest " , value.toString())
5859 })
5960
6061 cacheManager.get(key = " float" , success = { value, type ->
6162 assertEquals(5.55 , value)
62- assert (type!! .isInstance(Float ::class ))
63- System . out . println ( value.toString())
63+ assert (type.isInstance(Float ::class ))
64+ Log .d( " simpleCacheTest " , value.toString())
6465 })
6566
6667 cacheManager.get(key = " map" , success = { value, type ->
6768 assertEquals(testMap, value)
68- assert (type!! .isInstance(HashMap ::class ))
69- System . out . println ( value.toString())
69+ assert (type.isInstance(HashMap ::class ))
70+ Log .d( " simpleCacheTest " , value.toString())
7071 })
7172
7273 cacheManager.get(key = " obj" , success = { value, type ->
7374 assertEquals(testObject, value)
74- assert (type!! .isInstance(TestObject ::class ))
75- System . out . println ( value.toString())
75+ assert (type.isInstance(TestObject ::class ))
76+ Log .d( " simpleCacheTest " , value.toString())
7677 })
7778
7879 cacheManager.get(key = " obj2" , success = { value, type ->
7980 assertEquals(testObject2, value)
80- assert (type!! .isInstance(TestObject ::class ))
81- System . out . println ( value.toString())
81+ assert (type.isInstance(TestObject ::class ))
82+ Log .d( " simpleCacheTest " , value.toString())
8283 })
8384
8485 cacheManager.remove(" obj2" )
8586
8687 cacheManager.get(key = " obj2" , success = { _, _ ->
8788
8889 }, error = {
89- System . out . println ( " obj2 is not exist." )
90+ Log .d( " simpleCacheTest " , " obj2 is not exist." )
9091 assert (true )
9192 })
9293
93- System . out . println ( CacheManager .getListOfCacheFiles(appContext).toString())
94+ Log .d( " simpleCacheTest " , CacheManager .getListOfCacheFiles(appContext).toString())
9495
9596 assertEquals(" com.github.pcpl2.simplecache.test" , appContext.packageName)
9697 }
0 commit comments