Created
September 17, 2010 16:35
-
-
Save unclebob/584490 to your computer and use it in GitHub Desktop.
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
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static payroll.PayCalculator.calculate; | |
public class PayCalculatorTest { | |
private void assertPay(double expectedPay, double actualPay) { | |
assertEquals(expectedPay, actualPay, .001); | |
} | |
@Test | |
public void ZeroHours_ShouldBeZero() throws Exception { | |
assertPay(0.0, calculate(0, 10, true)); | |
assertPay(0.0, calculate(0, 10, false)); | |
} | |
@Test(expected = RuntimeException.class) | |
public void LessThanZeroHours_ShouldThrow() throws Exception { | |
calculate(-1, 10, true); | |
} | |
@Test(expected = RuntimeException.class) | |
public void MoreThan80Hours_ShouldThrow() throws Exception { | |
calculate(81, 10, true); | |
} | |
@Test | |
public void FortyHours_StraightTime() throws Exception { | |
assertPay(400.0, calculate(40, 10, true)); | |
assertPay(400.0, calculate(40, 10, false)); | |
} | |
@Test | |
public void FiftyHoursHourly_TimeAndHalf() throws Exception { | |
assertPay(550.0, calculate(50, 10, true)); | |
} | |
@Test | |
public void FiftyHoursNonHourly_StraightTime() throws Exception { | |
assertPay(500.0, calculate(50, 10, false)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment