From 9204d68e44a0e5b94543a0e673a06e65a6904631 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Wed, 26 Aug 2020 20:28:32 +0700 Subject: [PATCH] Add test source junit 5 and updated the exception --- build.gradle.kts | 1 + .../com/cubetiqs/libra/moneyutils/Main.kt | 13 ------------- .../moneyutils/MoneyCurrencyStateException.kt | 6 +++++- src/test/kotlin/MoneyTests.kt | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 14 deletions(-) delete mode 100644 src/main/kotlin/com/cubetiqs/libra/moneyutils/Main.kt create mode 100644 src/test/kotlin/MoneyTests.kt diff --git a/build.gradle.kts b/build.gradle.kts index ae41015..4e4edbc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,4 +11,5 @@ repositories { dependencies { implementation(kotlin("stdlib")) + testImplementation("org.junit.vintage:junit-vintage-engine:5.6.2") } diff --git a/src/main/kotlin/com/cubetiqs/libra/moneyutils/Main.kt b/src/main/kotlin/com/cubetiqs/libra/moneyutils/Main.kt deleted file mode 100644 index ea15932..0000000 --- a/src/main/kotlin/com/cubetiqs/libra/moneyutils/Main.kt +++ /dev/null @@ -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) -} \ No newline at end of file diff --git a/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyCurrencyStateException.kt b/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyCurrencyStateException.kt index 493cb0b..ac99f25 100644 --- a/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyCurrencyStateException.kt +++ b/src/main/kotlin/com/cubetiqs/libra/moneyutils/MoneyCurrencyStateException.kt @@ -1,3 +1,7 @@ package com.cubetiqs.libra.moneyutils -class MoneyCurrencyStateException(message: String? = null) : IllegalStateException(message ?: "money currency not found!") \ No newline at end of file +/** + * Default money currency state exception + */ +class MoneyCurrencyStateException(message: String? = null) : + IllegalStateException(message ?: "money currency is illegal state!") \ No newline at end of file diff --git a/src/test/kotlin/MoneyTests.kt b/src/test/kotlin/MoneyTests.kt new file mode 100644 index 0000000..2898aa1 --- /dev/null +++ b/src/test/kotlin/MoneyTests.kt @@ -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) + } +} \ No newline at end of file