|
1 |
| -package com.extensiblejava.test; |
2 |
| - |
3 |
| -import junit.framework.TestCase; |
4 |
| -import com.extensiblejava.employee.*; |
5 |
| -import java.math.BigDecimal; |
6 |
| - |
7 |
| -public class EmployeeTest extends TestCase { |
8 |
| - |
9 |
| - public static void main(String[] args) { |
10 |
| - junit.textui.TestRunner.run(EmployeeTest.class); |
11 |
| - } |
12 |
| - |
13 |
| - public void testEmployeePay() { |
14 |
| - |
15 |
| - PayrollRunner runner = new PayrollRunner() { |
16 |
| - public BigDecimal runPayroll(BigDecimal salary) { return new BigDecimal("500.00"); } |
17 |
| - }; |
18 |
| - Employee employee = new Employee(new Name(), new BigDecimal("20000.00")); |
19 |
| - PayCheck payCheck = employee.pay(runner); |
20 |
| - assertEquals(payCheck.getPay(), new BigDecimal("500.00")); |
21 |
| - |
22 |
| - } |
23 |
| -} |
| 1 | +package com.extensiblejava.test; |
| 2 | + |
| 3 | +import java.math.BigDecimal; |
| 4 | + |
| 5 | +import junit.framework.TestCase; |
| 6 | + |
| 7 | +import com.extensiblejava.employee.Employee; |
| 8 | +import com.extensiblejava.employee.Name; |
| 9 | +import com.extensiblejava.employee.PayCheck; |
| 10 | +import com.extensiblejava.employee.PayrollRunner; |
| 11 | +import com.extensiblejava.facade.PayFacade; |
| 12 | + |
| 13 | +public class EmployeeTest extends TestCase { |
| 14 | + |
| 15 | + public static void main(String[] args) { |
| 16 | + junit.textui.TestRunner.run(EmployeeTest.class); |
| 17 | + } |
| 18 | + |
| 19 | + public void testEmployeePayWithoutPayFacade() { |
| 20 | + |
| 21 | + PayrollRunner runner = new PayrollRunner() { |
| 22 | + public BigDecimal runPayroll(BigDecimal salary) { return new BigDecimal("500.00"); } |
| 23 | + }; |
| 24 | + Employee employee = new Employee(new Name(), new BigDecimal("20000.00")); |
| 25 | + PayCheck payCheck = employee.pay(runner); |
| 26 | + assertEquals(payCheck.getPay(), new BigDecimal("500.00")); |
| 27 | + |
| 28 | + } |
| 29 | + |
| 30 | + public void testEmployeePay() { |
| 31 | + PayFacade runner = new PayFacade(); |
| 32 | + Employee employee = new Employee(new Name(), new BigDecimal("20000.00")); |
| 33 | + PayCheck payCheck = employee.pay(runner); |
| 34 | + assertEquals(payCheck.getPay(), new BigDecimal("20000.00")); |
| 35 | + } |
| 36 | +} |
0 commit comments