1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.core.value;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.equalTo;
20 import static org.hamcrest.Matchers.hasItems;
21 import static org.hamcrest.Matchers.is;
22
23 import java.util.List;
24
25 import org.junit.Before;
26 import org.junit.Test;
27
28 import de.smartics.properties.spi.core.value.EnumeratedPropertyValueRange;
29 import de.smartics.testdoc.annotations.Uut;
30
31
32
33
34 @Uut(type=EnumeratedPropertyValueRange.class)
35 public class EnumeratedPropertyValueRangeTest
36 {
37
38
39
40
41
42
43 private EnumeratedPropertyValueRange<DummyEnumeration> uut;
44
45
46
47 private static enum DummyEnumeration
48 {
49 ELEMENT_1, ELEMENT_2;
50 }
51
52
53
54
55
56 @Before
57 public void setUp()
58 {
59 uut =
60 new EnumeratedPropertyValueRange<DummyEnumeration>(
61 DummyEnumeration.class);
62 }
63
64
65
66
67
68 @Test
69 public void providesAStringRepresentation()
70 {
71 final String result = uut.toString();
72
73 assertThat(result, is(equalTo("ELEMENT_1, ELEMENT_2")));
74 }
75
76 @Test
77 public void providesAnEnumerationElementInstanceFromAString()
78 {
79 final String enumElementName = DummyEnumeration.ELEMENT_2.name();
80
81 final DummyEnumeration enumElement = uut.fromString(enumElementName);
82
83 assertThat(enumElement, is(equalTo(DummyEnumeration.ELEMENT_2)));
84 }
85
86 @Test
87 public void allowsToRetrieveAllValues()
88 {
89 final List<DummyEnumeration> values = uut.getValues();
90
91 assertThat(values.size(), is(equalTo(2)));
92 assertThat(values,
93 hasItems(DummyEnumeration.ELEMENT_1, DummyEnumeration.ELEMENT_2));
94 }
95
96 @Test
97 public void providesAccessToTheEnumerationClass()
98 {
99 final Class<DummyEnumeration> type = uut.getEnumeration();
100
101 assertThat(type, is(equalTo(DummyEnumeration.class)));
102 assertThat(uut.isCommented(), is(true));
103 }
104 }