1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package ca.mokhan.test;
import Q10.*;
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());
}
public void test_UNKNOWN_status_Should_tax_at_33_percent() {
TaxReturn subject = new TaxReturn(100000, 3);
assertEquals(33000.0, subject.getTax());
}
}
|