01: package fit.decorator;
02:
03: import java.text.ParseException;
04:
05: import fit.Parse;
06: import fit.decorator.exceptions.InvalidInputException;
07: import fit.decorator.util.TestCaseHelper;
08:
09: public class LoopTest extends FixtureDecoratorTestCase {
10: private static final String FIRST_HTML_ROW = "<tr><td>"
11: + Loop.class.getName()
12: + "</td><td>1</td><td>times</td></tr>";
13: private FixtureDecorator decorator = new Loop();
14:
15: public void testSetupDecoratorShouldThrowInvalidInputExceptionIfLoopCountIsNotSpecified()
16: throws ParseException {
17: try {
18: decorator.setupDecorator(new String[0]);
19: fail("Should blow up");
20: } catch (InvalidInputException e) {
21: assertEquals("Loop count must be specified", e.getMessage());
22: }
23: }
24:
25: public void testSetupDecoratorShouldAddLoopCountToSummary()
26: throws Exception {
27: decorator.setupDecorator(new String[] { "5" });
28: assertEquals(5, ((Long) decorator.summary.get(Loop.COUNT))
29: .longValue());
30: }
31:
32: public void testShouldExecuteDoTableMethodLoopCounterNumberOfTimes()
33: throws Exception {
34: String fitPage = "<table><tr><td>"
35: + Loop.class.getName()
36: + "</td><td>5</td><td>times</td></tr><tr><td>eg.Division</td></tr>"
37: + "<tr><td>numerator</td><td>denominator</td><td>quotient()</td></tr>"
38: + "<tr><td>10</td><td>2</td><td>5</td></tr><tr><td>12.6</td><td>3</td><td>4.2</td></tr>"
39: + "<tr><td>100</td><td>4</td><td>25</td></tr></table>";
40: decorator.doTable(new Parse(fitPage));
41: TestCaseHelper.assertCounts(TestCaseHelper.counts(15, 0, 0, 0),
42: decorator.counts);
43: }
44:
45: protected String geDecoratorHTMLRow() {
46: return FIRST_HTML_ROW;
47: }
48:
49: protected int numberOfAssertionsOnDecorator() {
50: return 0;
51: }
52: }
|