From 66d26a2d83db1d159f01e38b25852cc5449dd578 Mon Sep 17 00:00:00 2001 From: Saksham Gupta Date: Thu, 3 Oct 2024 18:43:32 +0100 Subject: [PATCH] Add RewardValue class and unit tests for cash to miles conversion --- src/main/java/RewardValue.java | 4 ++++ src/test/java/RewardValueTests.java | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 src/main/java/RewardValue.java diff --git a/src/main/java/RewardValue.java b/src/main/java/RewardValue.java new file mode 100644 index 000000000..f24e46d18 --- /dev/null +++ b/src/main/java/RewardValue.java @@ -0,0 +1,4 @@ +package PACKAGE_NAME; + +public class RewardValue { +} diff --git a/src/test/java/RewardValueTests.java b/src/test/java/RewardValueTests.java index b3a78de7d..d651bf6da 100644 --- a/src/test/java/RewardValueTests.java +++ b/src/test/java/RewardValueTests.java @@ -1,5 +1,4 @@ import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertEquals; public class RewardValueTests { @@ -20,11 +19,17 @@ void create_with_miles_value() { @Test void convert_from_cash_to_miles() { - assert false; + double cashValue = 100; + var rewardValue = new RewardValue(cashValue); + int expectedMilesValue = (int) (cashValue / 0.02); // Assuming conversion rate is 1 mile = $0.02 + assertEquals(expectedMilesValue, rewardValue.getMilesValue()); } @Test void convert_from_miles_to_cash() { - assert false; + int milesValue = 10000; + var rewardValue = new RewardValue(milesValue); + double expectedCashValue = milesValue * 0.02; // Assuming conversion rate is 1 mile = $0.02 + assertEquals(expectedCashValue, rewardValue.getCashValue()); } -} +} \ No newline at end of file