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.
80 lines
2.4 KiB
80 lines
2.4 KiB
package net.pokeranalytics.android
|
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
|
import net.pokeranalytics.android.model.realm.Location
|
|
import net.pokeranalytics.android.model.realm.Session
|
|
import net.pokeranalytics.android.model.utils.FavoriteSessionFinder
|
|
import org.junit.Assert
|
|
import org.junit.Test
|
|
import org.junit.runner.RunWith
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
|
|
class FavoriteSessionUnitTest : RealmInstrumentedUnitTest() {
|
|
|
|
@Test
|
|
fun testFavoriteWithoutLocation() {
|
|
|
|
val realm = this.mockRealm
|
|
realm.beginTransaction()
|
|
|
|
val s1 = realm.createObject(Session::class.java, "1")
|
|
val s2 = realm.createObject(Session::class.java, "2")
|
|
val s3 = realm.createObject(Session::class.java, "3")
|
|
|
|
s1.cgBigBlind = 4.0
|
|
s2.cgBigBlind = 4.0
|
|
s3.cgBigBlind = 1.0
|
|
|
|
realm.insert(s1)
|
|
realm.insert(s2)
|
|
realm.insert(s3)
|
|
|
|
realm.commitTransaction()
|
|
val favSession = FavoriteSessionFinder.favoriteSession(Session.Type.CASH_GAME.ordinal, null, realm, InstrumentationRegistry.getInstrumentation().targetContext)
|
|
|
|
if (favSession != null) {
|
|
Assert.assertEquals(4.0, favSession.cgBigBlind)
|
|
} else {
|
|
Assert.fail("session shouldn't be null")
|
|
}
|
|
|
|
}
|
|
|
|
@Test
|
|
fun testFavoriteWithLocation() {
|
|
|
|
val realm = this.mockRealm
|
|
realm.beginTransaction()
|
|
|
|
val s1 = realm.createObject(Session::class.java, "1")
|
|
val s2 = realm.createObject(Session::class.java, "2")
|
|
val s3 = realm.createObject(Session::class.java, "3")
|
|
|
|
val loc1 = realm.createObject(Location::class.java, "1")
|
|
val loc2 = realm.createObject(Location::class.java, "2")
|
|
|
|
s1.cgBigBlind = 4.0
|
|
s2.cgBigBlind = 4.0
|
|
s3.cgBigBlind = 1.0
|
|
|
|
s1.location = loc1
|
|
s2.location = loc1
|
|
s3.location = loc2
|
|
|
|
realm.insert(s1)
|
|
realm.insert(s2)
|
|
realm.insert(s3)
|
|
|
|
realm.commitTransaction()
|
|
val favSession = FavoriteSessionFinder.favoriteSession(Session.Type.CASH_GAME.ordinal, loc2, realm, InstrumentationRegistry.getInstrumentation().targetContext)
|
|
|
|
if (favSession != null) {
|
|
Assert.assertEquals(1.0, favSession.cgBigBlind)
|
|
} else {
|
|
Assert.fail("session shouldn't be null")
|
|
}
|
|
|
|
}
|
|
} |