|
|
|
|
@ -5,10 +5,8 @@ import io.realm.Realm |
|
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollCalculator |
|
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollReportSetup |
|
|
|
|
import net.pokeranalytics.android.components.SessionInstrumentedUnitTest |
|
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
|
import net.pokeranalytics.android.model.realm.Session |
|
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
|
import net.pokeranalytics.android.model.realm.TransactionType |
|
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
|
import net.pokeranalytics.android.model.realm.Currency |
|
|
|
|
import org.junit.Assert |
|
|
|
|
import org.junit.Test |
|
|
|
|
import org.junit.runner.RunWith |
|
|
|
|
@ -75,8 +73,50 @@ class BankrollInstrumentedUnitTest : SessionInstrumentedUnitTest() { |
|
|
|
|
val report2 = BankrollCalculator.computeReport(brSetup2) |
|
|
|
|
Assert.assertEquals(2000.0, report2.total, EPSILON) |
|
|
|
|
|
|
|
|
|
val brSetupAll = BankrollReportSetup() |
|
|
|
|
val reportAll = BankrollCalculator.computeReport(brSetupAll) |
|
|
|
|
Assert.assertEquals(2400.0, reportAll.total, EPSILON) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun testReportWithRate() { |
|
|
|
|
|
|
|
|
|
val realm = mockRealm |
|
|
|
|
|
|
|
|
|
var br1: Bankroll? = null |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
|
|
|
|
|
this.createDefaultTransactionTypes(realm) |
|
|
|
|
|
|
|
|
|
val c1 = realm.createObject(Currency::class.java, UUID.randomUUID().toString()) |
|
|
|
|
c1.rate = 10.0 |
|
|
|
|
|
|
|
|
|
br1 = realm.createObject(Bankroll::class.java, "1") |
|
|
|
|
br1?.currency = c1 |
|
|
|
|
br1?.initialValue = 100.0 |
|
|
|
|
|
|
|
|
|
val t1 = realm.createObject(Transaction::class.java, UUID.randomUUID().toString()) |
|
|
|
|
t1.amount = 100.0 |
|
|
|
|
t1.type = TransactionType.getByValue(TransactionType.Value.BONUS, realm) |
|
|
|
|
br1?.transactions?.add(t1) |
|
|
|
|
|
|
|
|
|
val s1 = newSessionInstance(realm) |
|
|
|
|
s1.bankroll = br1 |
|
|
|
|
s1.result?.cashout = 200.0 |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val brSetup1 = BankrollReportSetup(br1) |
|
|
|
|
val report1 = BankrollCalculator.computeReport(brSetup1) |
|
|
|
|
Assert.assertEquals(400.0, report1.total, EPSILON) |
|
|
|
|
|
|
|
|
|
val brSetupAll = BankrollReportSetup() |
|
|
|
|
val reportAll = BankrollCalculator.computeReport(brSetupAll) |
|
|
|
|
Assert.assertEquals(4000.0, reportAll.total, EPSILON) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |