You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
package net.pokeranalytics.android
|
|
|
|
import io.realm.Realm
|
|
import io.realm.RealmConfiguration
|
|
import net.pokeranalytics.android.model.realm.ComputableResult
|
|
import net.pokeranalytics.android.model.realm.Result
|
|
import net.pokeranalytics.android.model.realm.Session
|
|
import org.junit.After
|
|
import org.junit.Before
|
|
import java.util.*
|
|
|
|
|
|
open class RealmInstrumentedUnitTest {
|
|
|
|
lateinit var mockRealm: Realm
|
|
|
|
companion object {
|
|
|
|
fun newSessionInstance(realm: Realm) : Session {
|
|
val session = realm.createObject(Session::class.java, UUID.randomUUID().toString())
|
|
val computableResult = realm.createObject(ComputableResult::class.java)
|
|
computableResult.session = session
|
|
session.result = realm.createObject(Result::class.java)
|
|
return session
|
|
}
|
|
|
|
}
|
|
|
|
@Before
|
|
fun setup() {
|
|
|
|
val testConfig = RealmConfiguration.Builder().inMemory().name("test-realm").build()
|
|
Realm.setDefaultConfiguration(testConfig)
|
|
this.mockRealm = Realm.getDefaultInstance()
|
|
|
|
this.mockRealm.executeTransaction {
|
|
this.mockRealm.deleteAll()
|
|
}
|
|
|
|
}
|
|
|
|
@After
|
|
@Throws(Exception::class)
|
|
public fun tearDown() {
|
|
this.mockRealm.close()
|
|
}
|
|
|
|
} |