Add test source junit 5 and updated the exception

This commit is contained in:
Sambo Chea 2020-08-26 20:28:32 +07:00
parent 226b97d7e9
commit 9204d68e44
4 changed files with 23 additions and 14 deletions

View File

@ -11,4 +11,5 @@ repositories {
dependencies { dependencies {
implementation(kotlin("stdlib")) implementation(kotlin("stdlib"))
testImplementation("org.junit.vintage:junit-vintage-engine:5.6.2")
} }

View File

@ -1,13 +0,0 @@
package com.cubetiqs.libra.moneyutils
class Main {
fun run() = print("Just mind!")
}
fun main() {
Main().run()
val money = Money(10.0)
val money2 = Money(20.0)
money *= money
println((money + money2) * money2)
}

View File

@ -1,3 +1,7 @@
package com.cubetiqs.libra.moneyutils package com.cubetiqs.libra.moneyutils
class MoneyCurrencyStateException(message: String? = null) : IllegalStateException(message ?: "money currency not found!") /**
* Default money currency state exception
*/
class MoneyCurrencyStateException(message: String? = null) :
IllegalStateException(message ?: "money currency is illegal state!")

View File

@ -0,0 +1,17 @@
import com.cubetiqs.libra.moneyutils.Money
import com.cubetiqs.libra.moneyutils.plus
import com.cubetiqs.libra.moneyutils.times
import com.cubetiqs.libra.moneyutils.timesAssign
import org.junit.Assert
import org.junit.Test
class MoneyTests {
@Test
fun test() {
val money = Money(10.0)
val money2 = Money(20.0)
money *= money
println((money + money2) * money2)
Assert.assertEquals(10, 10)
}
}