package net.pokeranalytics.android

import net.pokeranalytics.android.calculus.*
import net.pokeranalytics.android.model.realm.SessionSet
import org.junit.Assert.fail
import org.junit.Test

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */

class ExampleUnitTest : RealmUnitTest() {

    class Grade(someValue: Double) : SessionInterface {

        override var value: Double = someValue

        override var sessionSet: SessionSet? = SessionSet()
        override var estimatedHands: Double = 0.0
        override var bbNetResult: Double = 0.0
        override var bigBlindSessionCount: Int = 0 // 0 or 1
        override var buyin: Double = 0.0

    }

    @Test
    fun testStats() {

        val grades: List<Grade> = listOf(Grade(10.0), Grade(20.0))
        val group = SessionGroup(name = "test", sessions = grades)

        val results: ComputedResults = Calculator.compute(group, Calculator.Options())

        val sum = results.computedStat(Stat.NETRESULT)
        if (sum != null) {
            assert(sum.value == 30.0) { "sum is ${sum.value}" }
        } else {
            fail("No Net result stat")
        }

        val average = results.computedStat(Stat.AVERAGE)
        if (average != null) {
            assert(average.value == 15.0) { "average is ${average.value}" }
        } else {
            fail("No AVERAGE stat")
        }

    }


}
