-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from WISVCH/cleanup-payment-method
Cleanup Payment Method Code
- Loading branch information
Showing
3 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/test/java/ch/wisv/events/core/model/order/PaymentMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package ch.wisv.events.core.model.order; | ||
|
||
import ch.wisv.events.core.model.customer.Customer; | ||
import ch.wisv.events.core.model.product.Product; | ||
import ch.wisv.events.core.util.VatRate; | ||
import com.google.common.collect.ImmutableList; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class PaymentMethodTest { | ||
|
||
@Test | ||
public void testCalculateCostIncludingTransaction_Cash() { | ||
double cost = 50.0; | ||
PaymentMethod paymentMethod = PaymentMethod.CASH; | ||
|
||
double expected = 50.0; | ||
double actual = paymentMethod.calculateCostIncludingTransaction(cost); | ||
|
||
assertEquals(expected, actual, 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateCostIncludingTransaction_Card() { | ||
double cost = 50.0; | ||
PaymentMethod paymentMethod = PaymentMethod.CARD; | ||
|
||
double expected = 50.0; | ||
double actual = paymentMethod.calculateCostIncludingTransaction(cost); | ||
|
||
assertEquals(expected, actual, 0.001); | ||
} | ||
@Test | ||
public void testCalculateCostIncludingTransaction_IDEAL() { | ||
double cost = 50.0; | ||
PaymentMethod paymentMethod = PaymentMethod.IDEAL; | ||
|
||
double expected = 50.35; | ||
double actual = paymentMethod.calculateCostIncludingTransaction(cost); | ||
|
||
assertEquals(expected, actual, 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateCostIncludingTransaction_SOFORT() { | ||
double cost = 50.0; | ||
PaymentMethod paymentMethod = PaymentMethod.SOFORT; | ||
|
||
double expected = 50.85; // Rounded 50.847 | ||
double actual = paymentMethod.calculateCostIncludingTransaction(cost); | ||
|
||
assertEquals(expected, actual, 0.001); | ||
} | ||
|
||
@Test | ||
public void testCalculateCostIncludingTransaction_OTHER() { | ||
double cost = 50.0; | ||
PaymentMethod paymentMethod = PaymentMethod.OTHER; | ||
|
||
double expected = 50.0; // Since OTHER method has no transaction cost, the expected value should be same as the cost | ||
double actual = paymentMethod.calculateCostIncludingTransaction(cost); | ||
|
||
assertEquals(expected, actual, 0.001); | ||
} | ||
} |