1
2
3
4
5
6
7
8
9
10
11 package org.csveed.bean;
12
13 import static org.junit.jupiter.api.Assertions.assertFalse;
14 import static org.junit.jupiter.api.Assertions.assertTrue;
15
16 import org.csveed.common.Column;
17 import org.junit.jupiter.api.Test;
18
19
20
21
22 class DynamicColumnTest {
23
24
25
26
27 @Test
28 void advanceAndReset() {
29 int startColumn = 5;
30 int numberOfColumns = 7;
31 DynamicColumn column = new DynamicColumn(new Column(startColumn));
32 for (int i = 0; i < numberOfColumns - startColumn + 1; i++) {
33 column.advanceDynamicColumn();
34 assertFalse(column.atFirstDynamicColumn(), "Must not be at first column now");
35 column.checkForReset(numberOfColumns);
36 }
37 assertTrue(column.atFirstDynamicColumn(), "Must be at first dynamic column now");
38 }
39
40
41
42
43 @Test
44 void weHaveNoDynamicColumns() {
45 DynamicColumn column = new DynamicColumn(null);
46 column.advanceDynamicColumn();
47 assertTrue(column.atFirstDynamicColumn(), "Must be at first dynamic column now");
48 }
49
50
51
52
53 @Test
54 void activeDynamicColumns() {
55 Column activeColumn = new Column(4);
56 Column inactiveColumn = new Column(5);
57 DynamicColumn dynamicColumn = new DynamicColumn(activeColumn);
58 assertTrue(dynamicColumn.isDynamicColumnActive(activeColumn),
59 "Column " + activeColumn.getColumnIndex() + " must be active");
60 assertFalse(dynamicColumn.isDynamicColumnActive(inactiveColumn),
61 "Column " + inactiveColumn.getColumnIndex() + " must be active");
62 }
63 }