From 002fa35609ef5d8351275b02b10f5c56d9c37d26 Mon Sep 17 00:00:00 2001 From: George Herbert Date: Fri, 7 Feb 2020 10:15:25 +0000 Subject: [PATCH] New variables and making everything double (#2) --- README.md | 44 +++++---- .../hmrc/helptosavecalculator/Calculator.kt | 52 ++++++---- .../InvalidRegularPaymentException.kt | 2 +- .../models/CalculatorResponse.kt | 25 +++-- .../validation/RegularPaymentValidators.kt | 9 +- .../kotlin/uk/gov/hmrc/CalculatorTest.kt | 97 +++++++++++-------- .../models/CalculatorResponseTest.kt | 37 ++++--- .../RegularPaymentValidatorsTest.kt | 8 +- 8 files changed, 164 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index 2fb9b4e..28db7fa 100644 --- a/README.md +++ b/README.md @@ -4,49 +4,55 @@ ## Status [![Build Status](https://app.bitrise.io/app/6a0a30b884ce6131/status.svg?token=q0pKDUFK3Qfa6sXfy66vog&branch=master)](https://app.bitrise.io/app/6a0a30b884ce6131) ![LINE](https://img.shields.io/badge/line--coverage-98%25-brightgreen.svg) -![BRANCH](https://img.shields.io/badge/branch--coverage-86%25-brightgreen.svg) -![COMPLEXITY](https://img.shields.io/badge/complexity-1.48-brightgreen.svg) +![BRANCH](https://img.shields.io/badge/branch--coverage-82%25-brightgreen.svg) +![COMPLEXITY](https://img.shields.io/badge/complexity-1.64-brightgreen.svg) [ ![Download](https://api.bintray.com/packages/hmrc/mobile-releases/tax-kalculator/images/download.svg) ](https://bintray.com/hmrc/mobile-releases/help-to-save-kalculator/_latestVersion) ## Calculate help to save bonus ### For new users ```kotlin Calculator.run( - regularPayment = 50 // Must be between 1 and 50 + regularPayment = 50.0 // Must be between 1 and 50 ) ``` ### For users with existing accounts ```kotlin Calculator.run( - regularPayment = 50, // Must be between 1 and 50 - currentBalance = 100, - currentFirstPeriodBonus = 50.0, - currentSecondPeriodBonus = 0.0, - accountStartDate = DateTime() + regularPayment = 50.0, // Must be between 1 and 50 + currentBalance = 100.0, + currentPeriod1Bonus = 50.0, + currentPeriod2Bonus = 0.0, + accountStartDate = DateTime() ) ``` ## Response This will returns an object of type `CalculatorResponse`. This provide headline figures that are the results at the end of the scheme. However, if a monthly breakdown is needed a cumulative breakdown is provided in `monthlyBreakdown` -* `monthlyPayments: Int` +* `monthlyPayments: Double` * `monthlyBreakdown: List` * `monthNumber: Int` - * `balance: Int` - * `secondYearBonus: Double` - * `fourthYearBonus: Double` - * `totalBonusToDate: Double` -* `finalBalance: Int` -* `finalSecondYearBonus: Double` -* `finalFourthYearBonus: Double` + * `savingsToDate: Double` + * `period1Bonus: Double` + * `period2Bonus: Double` + * `bonusToDate: Double` +* `endOfSchemeBonus: Double` +* `endOfSchemeSavings: Double` +* `endOfSchemeTotal: Double` +* `endOfPeriod1Bonus: Double` +* `endOfPeriod1Savings: Double` +* `endOfPeriod1Total: Double` +* `endOfPeriod2Bonus: Double` +* `endOfPeriod2Savings: Double` +* `endOfPeriod2Total: Double` ## Validation To validate the monthly contributions: ```kotlin -val isValidRegularPayments = RegularPaymentValidators.isValidRegularPayments(1000) // true -val isAboveMinimumRegularPayments = RegularPaymentValidators.isAboveMinimumRegularPayments(0) // false -val isBelowMaximumRegularPayments = RegularPaymentValidators.isBelowMaximumRegularPayments(50) // true +val isValidRegularPayments = RegularPaymentValidators.isValidRegularPayments(1000.0) // true +val isAboveMinimumRegularPayments = RegularPaymentValidators.isAboveMinimumRegularPayments(0.0) // false +val isBelowMaximumRegularPayments = RegularPaymentValidators.isBelowMaximumRegularPayments(50.0) // true ``` ## Installation diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt index 302fb70..58af41a 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/Calculator.kt @@ -25,13 +25,13 @@ import uk.gov.hmrc.helptosavecalculator.validation.RegularPaymentValidators object Calculator : HtSSchemeConfig() { - fun run(regularPayment: Int): CalculatorResponse { + fun run(regularPayment: Double): CalculatorResponse { return calculate(regularPayment) } fun run( - regularPayment: Int, - currentBalance: Int, + regularPayment: Double, + currentBalance: Double, currentFirstPeriodBonus: Double, currentSecondPeriodBonus: Double, accountStartDate: DateTime @@ -41,48 +41,58 @@ object Calculator : HtSSchemeConfig() { } private fun calculate( - regularPayment: Int, - currentBalance: Int? = null, - currentFirstPeriodBonus: Double? = null, - currentSecondPeriodBonus: Double? = null, + regularPayment: Double, + currentBalance: Double? = null, + currentPeriod1Bonus: Double? = null, + currentPeriod2Bonus: Double? = null, accountStartDate: DateTime? = null ): CalculatorResponse { val listOfMonths: MutableList = mutableListOf() var currentMonth: Int = accountStartDate?.monthsSince()?.plus(1) ?: 1 - var balance: Int = currentBalance ?: 0 - var endOfFirstPeriodBonus: Double = currentFirstPeriodBonus ?: 0.0 - var endOfSecondPeriodBonus: Double = currentSecondPeriodBonus ?: 0.0 + var endOfSchemeSavings: Double = currentBalance ?: 0.0 + var endOfPeriod1Savings: Double = currentBalance ?: 0.0 + var endOfPeriod2Savings: Double = currentBalance ?: 0.0 + var endOfPeriod1Bonus: Double = currentPeriod1Bonus ?: 0.0 + var endOfPeriod2Bonus: Double = currentPeriod2Bonus ?: 0.0 validateUserInput(regularPayment) while (currentMonth <= endOfSecondBonusPeriod) { - balance += regularPayment + endOfSchemeSavings += regularPayment when (currentMonth) { in startOfFirstBonusPeriod..endOfFirstBonusPeriod -> { - endOfFirstPeriodBonus += (regularPayment / 2) + endOfPeriod1Bonus += (regularPayment / 2) + if (currentMonth == endOfFirstBonusPeriod) { + endOfPeriod1Savings = endOfSchemeSavings + } } in startOfSecondBonusPeriod..endOfSecondBonusPeriod -> { - endOfSecondPeriodBonus += (regularPayment / 2) + endOfPeriod2Bonus += (regularPayment / 2) + if (currentMonth == endOfSecondBonusPeriod) { + endOfPeriod2Savings = endOfSchemeSavings - endOfPeriod1Savings + } } else -> throw IllegalStateException("The scheme has exceeded 1 to 48 months") } listOfMonths.add( MonthlyBreakdown( monthNumber = currentMonth, - balance = balance, - secondYearBonus = endOfFirstPeriodBonus, - fourthYearBonus = endOfSecondPeriodBonus)) + savingsToDate = endOfSchemeSavings, + period1Bonus = endOfPeriod1Bonus, + period2Bonus = endOfPeriod2Bonus)) currentMonth++ } return CalculatorResponse( monthlyPayments = regularPayment, - finalBalance = balance, - finalSecondYearBonus = endOfFirstPeriodBonus, - finalFourthYearBonus = endOfSecondPeriodBonus, - monthlyBreakdown = listOfMonths) + monthlyBreakdown = listOfMonths, + endOfSchemeSavings = endOfSchemeSavings, + endOfPeriod1Bonus = endOfPeriod1Bonus, + endOfPeriod1Savings = endOfPeriod1Savings, + endOfPeriod2Bonus = endOfPeriod2Bonus, + endOfPeriod2Savings = endOfPeriod2Savings) } - private fun validateUserInput(regularPayment: Int) { + private fun validateUserInput(regularPayment: Double) { if (!RegularPaymentValidators.isValidRegularPayments(regularPayment)) { throw InvalidRegularPaymentException(regularPayment) } diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt index 7c7be2b..e3c851b 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/exceptions/InvalidRegularPaymentException.kt @@ -15,5 +15,5 @@ */ package uk.gov.hmrc.helptosavecalculator.exceptions -class InvalidRegularPaymentException(regularPayment: Int) : +class InvalidRegularPaymentException(regularPayment: Double) : Exception("Regular payment must be between 1 and 50. You provided $regularPayment") diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt index c271e5f..070ff8b 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponse.kt @@ -16,20 +16,25 @@ package uk.gov.hmrc.helptosavecalculator.models data class CalculatorResponse( - val monthlyPayments: Int, + val monthlyPayments: Double, val monthlyBreakdown: List, - val finalBalance: Int, - val finalSecondYearBonus: Double, - val finalFourthYearBonus: Double + val endOfSchemeSavings: Double, + val endOfPeriod1Bonus: Double, + val endOfPeriod1Savings: Double, + val endOfPeriod2Bonus: Double, + val endOfPeriod2Savings: Double ) { - val finalTotalBonus: Double = finalSecondYearBonus + finalFourthYearBonus -} + val endOfSchemeBonus: Double = endOfPeriod1Bonus + endOfPeriod2Bonus + val endOfSchemeTotal: Double = endOfSchemeSavings + endOfSchemeBonus + val endOfPeriod1Total: Double = endOfPeriod1Savings + endOfPeriod1Bonus + val endOfPeriod2Total: Double = endOfPeriod2Savings + endOfPeriod2Bonus + } data class MonthlyBreakdown( val monthNumber: Int, - val balance: Int, - val secondYearBonus: Double, - val fourthYearBonus: Double + val savingsToDate: Double, + val period1Bonus: Double, + val period2Bonus: Double ) { - val totalBonusToDate: Double = secondYearBonus + fourthYearBonus + val bonusToDate: Double = period1Bonus + period2Bonus } diff --git a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt index 7a3c11c..c9ba248 100644 --- a/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt +++ b/src/commonMain/kotlin/uk/gov/hmrc/helptosavecalculator/validation/RegularPaymentValidators.kt @@ -17,10 +17,11 @@ package uk.gov.hmrc.helptosavecalculator.validation object RegularPaymentValidators { - fun isValidRegularPayments(payment: Int) = isBelowMaximumRegularPayments(payment) && isAboveMinimumRegularPayments( - payment) + fun isValidRegularPayments(payment: Double) = + isBelowMaximumRegularPayments(payment) && isAboveMinimumRegularPayments( + payment) - fun isAboveMinimumRegularPayments(payment: Int) = payment >= 1 + fun isAboveMinimumRegularPayments(payment: Double) = payment >= 1.0 - fun isBelowMaximumRegularPayments(payment: Int) = payment <= 50 + fun isBelowMaximumRegularPayments(payment: Double) = payment <= 50.0 } diff --git a/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt index 994922c..e03c21e 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/CalculatorTest.kt @@ -28,94 +28,113 @@ class CalculatorTest { @Test fun `Gives list of 48 months with breakdown`() { assertEquals( - MonthlyBreakdown(monthNumber = 1, balance = 50, secondYearBonus = 25.0, fourthYearBonus = 0.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[0]) - assertEquals(25.0, Calculator.run(regularPayment = 50).monthlyBreakdown[0].totalBonusToDate) + MonthlyBreakdown(monthNumber = 1, savingsToDate = 50.0, period1Bonus = 25.0, period2Bonus = 0.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[0]) + assertEquals(25.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[0].bonusToDate) assertEquals( - MonthlyBreakdown(monthNumber = 2, balance = 100, secondYearBonus = 50.0, fourthYearBonus = 0.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[1]) - assertEquals(50.0, Calculator.run(regularPayment = 50).monthlyBreakdown[1].totalBonusToDate) + MonthlyBreakdown(monthNumber = 2, savingsToDate = 100.0, period1Bonus = 50.0, period2Bonus = 0.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[1]) + assertEquals(50.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[1].bonusToDate) assertEquals( - MonthlyBreakdown(monthNumber = 3, balance = 150, secondYearBonus = 75.0, fourthYearBonus = 0.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[2]) - assertEquals(50.0, Calculator.run(regularPayment = 50).monthlyBreakdown[1].totalBonusToDate) + MonthlyBreakdown(monthNumber = 3, savingsToDate = 150.0, period1Bonus = 75.0, period2Bonus = 0.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[2]) + assertEquals(50.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[1].bonusToDate) assertEquals( - MonthlyBreakdown(monthNumber = 24, balance = 1200, secondYearBonus = 600.0, fourthYearBonus = 0.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[23]) - assertEquals(600.0, Calculator.run(regularPayment = 50).monthlyBreakdown[23].totalBonusToDate) + MonthlyBreakdown(monthNumber = 24, savingsToDate = 1200.0, period1Bonus = 600.0, period2Bonus = 0.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[23]) + assertEquals(600.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[23].bonusToDate) assertEquals( MonthlyBreakdown( - monthNumber = 25, balance = 1250, secondYearBonus = 600.0, fourthYearBonus = 25.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[24]) - assertEquals(625.0, Calculator.run(regularPayment = 50).monthlyBreakdown[24].totalBonusToDate) + monthNumber = 25, savingsToDate = 1250.0, period1Bonus = 600.0, period2Bonus = 25.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[24]) + assertEquals(625.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[24].bonusToDate) assertEquals( MonthlyBreakdown( - monthNumber = 48, balance = 2400, secondYearBonus = 600.0, fourthYearBonus = 600.0), - Calculator.run(regularPayment = 50).monthlyBreakdown[47]) - assertEquals(1200.0, Calculator.run(regularPayment = 50).monthlyBreakdown[47].totalBonusToDate) + monthNumber = 48, savingsToDate = 2400.0, period1Bonus = 600.0, period2Bonus = 600.0), + Calculator.run(regularPayment = 50.0).monthlyBreakdown[47]) + assertEquals(1200.0, Calculator.run(regularPayment = 50.0).monthlyBreakdown[47].bonusToDate) } @Test fun `Throw Exception when regular payment is below 1`() { assertFailsWith { - Calculator.run(regularPayment = 0) + Calculator.run(regularPayment = 0.0) } } @Test fun `Throw Exception when regular payment is above 50`() { assertFailsWith { - Calculator.run(regularPayment = 51) + Calculator.run(regularPayment = 51.0) } } @Test - fun `Month breakdown if they have only saved in the first 2 months`() { + fun `Month breakdown if they have saved in the first 2 months`() { val calculator = Calculator.run( - regularPayment = 50, - currentBalance = 100, + regularPayment = 50.0, + currentBalance = 100.0, currentFirstPeriodBonus = 50.0, currentSecondPeriodBonus = 0.0, accountStartDate = DateTime.now().minus( MonthSpan(2))) - assertEquals(2400, calculator.finalBalance) - assertEquals(600.0, calculator.finalSecondYearBonus) - assertEquals(600.0, calculator.finalFourthYearBonus) - assertEquals(1200.0, calculator.finalTotalBonus) + + assertEquals(2400.0, calculator.endOfSchemeSavings) + assertEquals(1200.0, calculator.endOfSchemeBonus) + assertEquals(3600.0, calculator.endOfSchemeTotal) + + assertEquals(600.0, calculator.endOfPeriod1Bonus) + assertEquals(1200.0, calculator.endOfPeriod1Savings) + assertEquals(1800.0, calculator.endOfPeriod1Total) + + assertEquals(600.0, calculator.endOfPeriod2Bonus) + assertEquals(1200.0, calculator.endOfPeriod2Savings) + assertEquals(1800.0, calculator.endOfPeriod2Total) } @Test fun `Month breakdown if they have not saved in the first 2 months`() { val calculator = Calculator.run( - regularPayment = 50, - currentBalance = 0, + regularPayment = 50.0, + currentBalance = 0.0, currentFirstPeriodBonus = 0.0, currentSecondPeriodBonus = 0.0, accountStartDate = DateTime.now().minus( MonthSpan(2))) - assertEquals(2300, calculator.finalBalance) - assertEquals(550.0, calculator.finalSecondYearBonus) - assertEquals(600.0, calculator.finalFourthYearBonus) - assertEquals(1150.0, calculator.finalTotalBonus) + assertEquals(2300.0, calculator.endOfSchemeSavings) + assertEquals(1150.0, calculator.endOfSchemeBonus) + assertEquals(3450.0, calculator.endOfSchemeTotal) + + assertEquals(550.0, calculator.endOfPeriod1Bonus) + assertEquals(1100.0, calculator.endOfPeriod1Savings) + assertEquals(1650.0, calculator.endOfPeriod1Total) + assertEquals(600.0, calculator.endOfPeriod2Bonus) + assertEquals(1200.0, calculator.endOfPeriod2Savings) + assertEquals(1800.0, calculator.endOfPeriod2Total) } @Test fun `Month breakdown if they have not saved in the first 24 months`() { val calculator = Calculator.run( - regularPayment = 50, - currentBalance = 0, + regularPayment = 50.0, + currentBalance = 0.0, currentFirstPeriodBonus = 0.0, currentSecondPeriodBonus = 0.0, accountStartDate = DateTime.now().minus( MonthSpan(24))) - assertEquals(1200, calculator.finalBalance) - assertEquals(0.0, calculator.finalSecondYearBonus) - assertEquals(600.0, calculator.finalFourthYearBonus) - assertEquals(600.0, calculator.finalTotalBonus) + assertEquals(1800.0, calculator.endOfSchemeTotal) + assertEquals(1200.0, calculator.endOfSchemeSavings) + assertEquals(600.0, calculator.endOfSchemeBonus) + assertEquals(0.0, calculator.endOfPeriod1Bonus) + assertEquals(0.0, calculator.endOfPeriod1Savings) + assertEquals(0.0, calculator.endOfPeriod1Total) + assertEquals(600.0, calculator.endOfPeriod2Bonus) + assertEquals(1200.0, calculator.endOfPeriod2Savings) + assertEquals(1800.0, calculator.endOfPeriod2Total) } } diff --git a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt index f04077f..15a0e66 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/models/CalculatorResponseTest.kt @@ -22,28 +22,41 @@ class CalculatorResponseTest { @Test fun `Check getters on Calculator Response`() { - val calculatorResponse = CalculatorResponse(50, listOf(), 2400, 600.0, 600.0) + val calculatorResponse = CalculatorResponse( + monthlyPayments = 50.0, + monthlyBreakdown = listOf(), + endOfSchemeSavings = 2400.0, + endOfPeriod1Bonus = 600.0, + endOfPeriod1Savings = 1200.0, + endOfPeriod2Bonus = 600.0, + endOfPeriod2Savings = 1200.0) - assertEquals(calculatorResponse.finalTotalBonus, 1200.0) - assertEquals(calculatorResponse.monthlyPayments, 50) + assertEquals(calculatorResponse.endOfSchemeBonus, 1200.0) + assertEquals(calculatorResponse.monthlyPayments, 50.0) assertEquals(calculatorResponse.monthlyBreakdown, listOf()) - assertEquals(calculatorResponse.finalBalance, 2400) - assertEquals(calculatorResponse.finalSecondYearBonus, 600.0) - assertEquals(calculatorResponse.finalFourthYearBonus, 600.0) - assertEquals(calculatorResponse.finalTotalBonus, 1200.0) + assertEquals(calculatorResponse.endOfSchemeSavings, 2400.0) + assertEquals(calculatorResponse.endOfSchemeBonus, 1200.0) + assertEquals(calculatorResponse.endOfSchemeTotal, 3600.0) + + assertEquals(calculatorResponse.endOfPeriod1Bonus, 600.0) + assertEquals(calculatorResponse.endOfPeriod1Savings, 1200.0) + assertEquals(calculatorResponse.endOfPeriod1Total, 1800.0) + assertEquals(calculatorResponse.endOfPeriod2Bonus, 600.0) + assertEquals(calculatorResponse.endOfPeriod2Savings, 1200.0) + assertEquals(calculatorResponse.endOfPeriod2Total, 1800.0) } @Test fun `Check getters on MonthlyBreakdown`() { val monthlyBreakdown = MonthlyBreakdown( - monthNumber = 1, balance = 50, secondYearBonus = 25.0, fourthYearBonus = 0.0) + monthNumber = 1, savingsToDate = 50.0, period1Bonus = 25.0, period2Bonus = 0.0) // val balance: Int, val secondYearBonus: Double, val fourthYearBonus: Double assertEquals(monthlyBreakdown.monthNumber, 1) - assertEquals(monthlyBreakdown.balance, 50) - assertEquals(monthlyBreakdown.secondYearBonus, 25.0) - assertEquals(monthlyBreakdown.fourthYearBonus, 0.0) - assertEquals(monthlyBreakdown.totalBonusToDate, 25.0) + assertEquals(monthlyBreakdown.savingsToDate, 50.0) + assertEquals(monthlyBreakdown.period1Bonus, 25.0) + assertEquals(monthlyBreakdown.period2Bonus, 0.0) + assertEquals(monthlyBreakdown.bonusToDate, 25.0) } } diff --git a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt index 8403828..a17f320 100644 --- a/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt +++ b/src/commonTest/kotlin/uk/gov/hmrc/helptosavecalculator/utils/validators/RegularPaymentValidatorsTest.kt @@ -24,21 +24,21 @@ class RegularPaymentValidatorsTests { @Test fun `Validate RegularPayments below minimum`() { - assertFalse(RegularPaymentValidators.isAboveMinimumRegularPayments(0)) + assertFalse(RegularPaymentValidators.isAboveMinimumRegularPayments(0.0)) } @Test fun `Validate RegularPayments above zero`() { - assertTrue(RegularPaymentValidators.isAboveMinimumRegularPayments(1)) + assertTrue(RegularPaymentValidators.isAboveMinimumRegularPayments(1.0)) } @Test fun `Validate RegularPayments below max`() { - assertTrue(RegularPaymentValidators.isBelowMaximumRegularPayments(50)) + assertTrue(RegularPaymentValidators.isBelowMaximumRegularPayments(50.0)) } @Test fun `Validate RegularPayments above max`() { - assertFalse(RegularPaymentValidators.isBelowMaximumRegularPayments(51)) + assertFalse(RegularPaymentValidators.isBelowMaximumRegularPayments(51.0)) } }