summaryrefslogtreecommitdiff
path: root/src/section-10/TaxReturnTest.java
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-05 19:48:09 -0600
committermokha <mokha@cisco.com>2019-05-05 19:48:09 -0600
commit99a28d2dba93642e89a62ecf905a3bd4f138318d (patch)
treeee10a7df683642a42991896bbec5ced501a2abd1 /src/section-10/TaxReturnTest.java
parent3c2be35d16d7482442911f5b06b68512f86e15b5 (diff)
split code into directories closer to what the instructor wants
Diffstat (limited to 'src/section-10/TaxReturnTest.java')
-rw-r--r--src/section-10/TaxReturnTest.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/section-10/TaxReturnTest.java b/src/section-10/TaxReturnTest.java
new file mode 100644
index 0000000..474f899
--- /dev/null
+++ b/src/section-10/TaxReturnTest.java
@@ -0,0 +1,85 @@
+package ca.mokhan.assignment1;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TaxReturnTest extends TestCase {
+ public TaxReturnTest(String testName) {
+ super(testName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TaxReturnTest.class);
+ }
+
+ public void test_SINGLE_BRACKET1() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET1 - 0.01, TaxReturn.SINGLE);
+ assertEquals(3217.4985, subject.getTax());
+ }
+
+ public void test_SINGLE_BRACKET1_1_CHILD() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET1 - 0.01, TaxReturn.SINGLE, 1);
+ assertEquals(2467.4985, subject.getTax());
+ }
+
+ public void test_SINGLE_BRACKET1_2_CHILDREN() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET1 - 0.01, TaxReturn.SINGLE, 2);
+ assertEquals(1717.4985000000001, subject.getTax());
+ }
+
+ public void test_SINGLE_BRACKET1_3_CHILDREN() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET1 - 0.01, TaxReturn.SINGLE, 3);
+ assertEquals(967.4985000000001, subject.getTax());
+ }
+
+ public void test_SINGLE_BRACKET2() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET2 - 0.01, TaxReturn.SINGLE);
+ assertEquals(11743.4972, subject.getTax());
+ }
+
+ public void test_SINGLE_BRACKET3() {
+ TaxReturn subject = new TaxReturn(TaxReturn.SINGLE_BRACKET2 + 0.01, TaxReturn.SINGLE);
+ assertEquals(11743.5031, subject.getTax());
+ }
+
+ // if the income is greater than $249,999 for SINGLE, then add a tax of 25% on income amount above
+ // $150,000;
+ public void test_SINGLE_Income_Greater_Than_250K() {
+ // $0 - $21450: 0.15% = $3,217.5
+ // $21450 - $51900: 0.28% = $8,526.0
+ // $51900 - $250,000: 0.31% = $61411.0
+ // $150,000 - $250,000: 0.25% = $25,000.0
+ // total: $98,154.50
+
+ TaxReturn subject = new TaxReturn(250000, TaxReturn.SINGLE);
+ assertEquals(98154.50, subject.getTax());
+ }
+
+ public void test_MARRIED_BRACKET1() {
+ TaxReturn subject = new TaxReturn(TaxReturn.MARRIED_BRACKET1 - 0.01, TaxReturn.MARRIED);
+ assertEquals(5369.9985, subject.getTax());
+ }
+
+ public void test_MARRIED_BRACKET2() {
+ TaxReturn subject = new TaxReturn(TaxReturn.MARRIED_BRACKET2 - 0.01, TaxReturn.MARRIED);
+ assertEquals(19565.997200000005, subject.getTax());
+ }
+
+ public void test_MARRIED_BRACKET3() {
+ TaxReturn subject = new TaxReturn(TaxReturn.MARRIED_BRACKET2 + 0.01, TaxReturn.MARRIED);
+ assertEquals(19566.003099999998, subject.getTax());
+ }
+
+ // if the income is greater than $349,999 for MARRIED, then add a tax of 35% on income amount
+ // above $200,000.
+ public void test_MARRIED_Income_Greater_Than_350K() {
+ // $0 - $35,800: 0.15% = $5,370.0
+ // $35,800 - $86,500: 0.28% = $14196.000000000002
+ // $86,500 - $350,000: 0.31% = $81685.0
+ // $200,000 - $350,000: 0.35% = $52500.0
+ // total: $153,751.0
+ TaxReturn subject = new TaxReturn(350000, TaxReturn.MARRIED);
+ assertEquals(153751.0, subject.getTax());
+ }
+}